Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

subtract 120 days from date

Hello.

I have a problem, I need to subtract 120 days to a date and I can not.

Subtraction is a field that is not master calendar, I use a MAKEDATE (year, month, day) to create the date, but everything I use does not give correct results.

Anyone have any idea?

Thanks and regards

9 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     All you have to do is just say    Date - 120.

     Look what output it gives, if its number then you can try this.  Date(Date - 120).

     What are the things you have tried?

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Hi there,

Why not use INTERVAL to subtract 120 days from your date?

For example:

Front end

date(interval([YOUR DATE] - 120,'D'),'YYYY/MM/DD')

Script

date(interval([YOUR DATE] - 120,'D'),'YYYY/MM/DD') as "NEW DATE"

Hope this helps,

Regards GJ


Not applicable
Author

Hi,

Please Try this.......

=Date(makedate(2012,01,27)-120)

Thanks & Regards,

Parag Patil

Not applicable
Author

Thank you all for your responses.

My first question is not complete, I had an error.

I need to calculate the amount of the selected date minus 120 days. I can not make it work with any of your suggestions

Attached qvw.

thanks

Not applicable
Author

Hi Gabriel,

If you haven't figured it out already here's a solution that works well for me

Assume you create a date like so:

LET zcurrDate = Date(MakeDate(Year(Today()), Month(Today()), Day(Today()))), 'YYYYMMDD');  //Result in this case is 20121002

to calculate a date going back n days

LET zPrevdate = Date(Date#($(zcurrDate), 'YYYYMMDD')-n, 'YYYYMMDD'); //where n=120

Lets break the above down (inside to out):

Date#($(zcurrDate), 'YYYYMMDD')-120 //Result after subtracting 120 days from 20121002 is 41064

takes string input so your date would essentially be in "string format" already, from what i see in terms of your data source in your QVW, but returns the date

in a "proper"date format that Qlikview can correctly manipulate, so subtracting 120 from the date will return a date in a number format i.e 41064 in this case

Putting the above Date# result into the "regular" Date function will convert the date as a number into a readable format i.e Date(41064) = 20120604

Works everytime for me, hope it does for you too and I hope my explanation (according to how I understand it) makes sense.

Not applicable
Author

Thanks, this just helped me workout some of my solutions, but i have a question, how can I display

Start date is = Today()?

Start date = 2012/11/02

Thanks in advance

Edzi

Not applicable
Author

Hi

Try this

sum({<datefield={"=$(=date(today()-30))"}>}amount)

CELAMBARASAN
Partner - Champion
Partner - Champion

Use Date(Num(MAKEDATE (year, month, day) )-120) then you will get the date before 120 days.

Anonymous
Not applicable
Author

=date(today()-1