Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Count the days between two dates

Hello,

Can you tell me how can I count the days between two dates ?

I want to create a chart with opened cases and I have to create some dimensions in days.

<7 days 14-14 days 14-30 days 30-90 days.

print.png

Similar to this chart.

And I don't have any ideas how to do this. Can you give me a clue ?

Thanks!

1 Solution

Accepted Solutions
sasiparupudi1
Master III
Master III

Use a calculated dimension with an if condition like below

if (Interval(DateField2 - DateField1,'D')<7,'<7 days',

   if(Interval(DateField2 - DateField1,'D')>7 and Interval(DateField2 - DateField1,'D')<14,'7-14 days',

   if(Interval(DateField2 - DateField1,'D')>14 and Interval(DateField2 - DateField1,'D')<30,'14-30 days',

   if(Interval(DateField2 - DateField1,'D')>30 and Interval(DateField2 - DateField1,'D')<90,'30-90 days','>90 Days'))))

hth

Sasi

View solution in original post

11 Replies
Not applicable
Author

Hi,

Can you share your qvw file or sample file.

gautik92
Specialist III
Specialist III

=fabs(Date(EndDate,'DD/MM/YYYY')) - fabs(Date(StartDate,'DD/MM/YYYY'))

Not applicable
Author

Is not working.

sasiparupudi1
Master III
Master III

Use a calculated dimension with an if condition like below

if (Interval(DateField2 - DateField1,'D')<7,'<7 days',

   if(Interval(DateField2 - DateField1,'D')>7 and Interval(DateField2 - DateField1,'D')<14,'7-14 days',

   if(Interval(DateField2 - DateField1,'D')>14 and Interval(DateField2 - DateField1,'D')<30,'14-30 days',

   if(Interval(DateField2 - DateField1,'D')>30 and Interval(DateField2 - DateField1,'D')<90,'30-90 days','>90 Days'))))

hth

Sasi

gautik92
Specialist III
Specialist III

can you share sample qvw file?

Not applicable
Author

Hi try this:

If date field don't have time stamp

         Date(todate)-date(frondate) as date-count

If time stamp first u have to trim the time then use above statement

gautik92
Specialist III
Specialist III

have a look at jontydkpi reply for the thread

difference between two dates.

it might help you

Not applicable
Author

Thank you ! Very helpful.

Not applicable
Author

Thank you very much !