Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Difference between two dates

Hi,

I have one requirement where date difference should be 1 year. like below example

Today is 8th Feb 2011. I want to create one button which should select 1 year difference like 1st Feb 2010 to 31st Jan 2011 so the difference is 1 year.

If I refresh the dashboard in coming month from 1st march 2011 to 31st March 2011 then the Data selection should be 1st March 2010 to 29th Feb 2011.

Could you pls let me know how to implement this requirement.

Thanks,

4 Replies
brenner_martina
Partner - Specialist II
Partner - Specialist II

Hi,

you can use a lot of datefunctions:

Year(Datefield) and (Year(Datefield)-1)

Makedate(Year(Datefield),Month(Datefiled),Day(Datefield)) and

Makedate((Year(Datefield)-1),Month(Datefiled),Day(Datefield))

disqr_rm
Partner - Specialist III
Partner - Specialist III

Create a button and put Action to select your Date field with following value expression:

='>' & addmonths(today(), -12) & ' <' & today()

This should select last 1 year dates, provided your Date field is actually a valid Date type content.

Hope this helps you.

Not applicable
Author

Thanks Rakesh, but I am not sue how to proceed. I just created one button and under action tab I clicked on Add buttton here I have question what should I select and where I have to paste this formula?

But if I click on that button it should select 1 year difference data

Thanks,

disqr_rm
Partner - Specialist III
Partner - Specialist III

Under Actions tab press "Add" button

Action type: Selection, Action: Select in Field, Press OK

In the field "Field" on the right, type the field name in your data model you want to select these days.

In the "Search String" field enter the expression I gave you: ='>' & addmonths(today(), -12) & ' <' & today()

Press OK and try the button.