Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Date comparison

Hi,

I need to compare whether the end date is within next 5 days from the current date ,where end date is a column having date entries.Incase the end date is within forth coming 5 days i would want to display 'Y',else 'N'.Can anyone let me know how this could be accomplished?

6 Replies
swuehl
MVP
MVP

I would do this in the script:

Set DateFormat = 'MM/DD/YYYY';      //Whatever your input date format is

LOAD

     EndDate,

     if(EndDate -Today(1) <=5 and EndDate -Today(1) >0, 'Y','N') as EndDateFlag,

     ....

FROM .... ;

Not applicable
Author

But,I do not want to make any changes to the script I want it to be done in the front end

swuehl
MVP
MVP

You can use the same logic in a table chart expression, when your dimension granularity is your end date:

=if(EndDate -Today(1) <=5 and EndDate -Today(1) >0, 'Y','N')

Not applicable
Author

in front end--

then prperties of pivot/straight-->number tab--> select radio button of  Date --> then write format of date which you want

Not applicable
Author

Hi Swuehl,

I am new to qlikview and thus I am not familiar with today() function .Can you please explain when and where is it used. So that I am aware of the results that would be expected (I specifically want to understand the result of today(1))

swuehl
MVP
MVP

From the HELP file (e.g. by pressing F1):

today([timer_mode] )

Returns the current date from the system clock. The timer_mode may have the following values:

0 Date at script run
1 Date at function call
2 Date when the document was opened  

Default timer_mode is 2. The timer_mode = 1 should be used with caution, since it polls the operating system every second and hence could slow down the system.

So using today(1) in the front end is not a good idea, I should have changed the timer mode to e.g. 2 when copying the expression from the script.