Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Writing a Expression to subract dates,

Hi,

I want to write a expression in which i need to subtract the two dates field and i need to convert the result field in to hours, days and minutes. I am looking for the syntax to follow and little confused with the functions to use,

Any help will be highly appreciated,

Thanks,

Praveen.

25 Replies
CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

     Use interval function

     interval(MaxDate-MinDate,'D hh:mm')

Hope it helps

Celambarasan  

Not applicable
Author

Celambarasan is already answered it...

FYI for getting the data in hours... change the format to interval(EndDate-StartDate,'hh:mm:ss')

jagan
Partner - Champion III
Partner - Champion III

Hi,

Use Interval(), for getting the difference

Ex:

Interval(StartDate - EndDate, 'D hh:mm')

Regards,

Jagan.

Not applicable
Author

Hi,

I am not getting correct results, by default in the output it throws the date columns and it shows hours and seconds. I want to display only hours and seconds and most importantly i need to sum it.

For eg i need to sum(hours) and sum(minutes) and display it one row.

Any help towards this,

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi

   Try this

   num#(intervalmatch(Date1 - Date2,'d'),'##') as Day

   num#(intervalmatch(Date1 - Date2,'hh'),'##') as Hour

   Now you can sum them

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

still am not getting the correct answer, the above syntax doesnot works. I need to remove match in that, only then it works.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Oh yes its my typing mistake, apologies for that.

     Are you getting correct answer when you use Interval in above expression?

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

still i am not getting, one of the columns used in interval function also throws in output, i need only the hrs and minutes,

Any help??

CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

         Can you please tel me about your problem in brief ?

Celambarasan