Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

date difference for same days should return 1

Hi,

     I have 2 dates - start date and end date. If start date = end date I should get the date difference as 1. If start date is today and end date is tomm. then the date difference should be 2. How do I get this.

I tried with interval and added 1 to it...does not work when using aggregate functions like sum etc.

Thanks

Lax

4 Replies
Not applicable
Author

Hi ,

Add 1 to your resultant expression where the difference is getting calculated.

This will help.

For example :

 

num((date#('13/12/2014','DD/MM/YYYY')- date#('12/12/2014','DD/MM/YYYY'))+1,'#')                      = > 2

 

num((date#('12/12/2014','DD/MM/YYYY')- date#('12/12/2014','DD/MM/YYYY'))+1,'#')                      =>1

Thanks

sujeetsingh
Master III
Master III

just use nested if statement

if(Startdate=Enddate,1,

   if(Startdate=today() and Enddate=today()+1,2,interval(Startdate-Enddate,'d')))

Something like this try

-----note may be there some symtax issue.

senpradip007
Specialist III
Specialist III

try this

=If('1/14/2014' = Today(), 1, '1/16/2014' - Today() + 1 )

Clever_Anjos
Employee
Employee

Floor(vEnd) - Floor(vStart) + 1