Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Add number to a date

Hello ,

I am trying to add a number stored in a variable or a column in the table to a date and this is to calculate the Sum for prior year.

But none of the below seems to work,

Date(MyDate+$(vNoofDays))

Date(Date(MyDate,'MM/DD/YYYY')+ColumnName)

Date(Date(MyDate,'MM/DD/YYYY')+ColumnName,'MM/DD/YYYY')


However, if i tried to add a number, it works.

Please help.

4 Replies
sunny_talwar

Is your date correctly interpreted as date field? Check these links out:

Get the Dates Right

Why don’t my dates work?

and then once those are fixed, you might be able to just do this:

Date(MyDate + vNoofDays)

Not applicable
Author

Thanks for your reply Sunny. What i am trying to achieve here is the comparison between Sales of Current Year with prior Year. And for Current Year,

YTD is

=Sum({<FISCALYEAR={"$(=YearofToday)"},DateNum={">=$(=Num(FISCALYEARSTART))<=$(=Num(Today()))"}>} Sales)

But for prior year, i want the Sales to be calculated for the same number of days of the Current Year for which the YTD was calculated , but for the Proevious year. Eg: Assume, CY YTD the no of days is 200 from the FISCAL Year STRT to today.

So, my Prior Year YTD should start from 2015's FISCAL Year START and add the no of days 200, and sum the Sales.

I am stuck at adding the no of days and it is not working.

tyagishaila
Specialist
Specialist

It should be,

Dim: YourDateField

Expression: Date( YourDateField + vNoofdays)

anagharao
Creator II
Creator II

Hi,

Why not change the fiscal year to be pervious yr?

=Sum({<FISCALYEAR={"$(=PrYearofToday)"},DateNum={">=$(=Num(FISCALYEARSTART))<=$(=Num(Today()))"}>} Sales)

Regards,

Anagha