Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
jpjust
Specialist
Specialist

Date Difference Calculation

All,

I would like to calculate the date difference.

Have a table like below.

Task Name         Last Reload                                             Next Execution                                Frequency

Task A                    2021-10-13 06:55:27                            13/10/2021 07:55:20                       1 Hr

The expressions are below.

Last Reload - timestamp(Max(LogTimeStamp))

Next Execution  =TimeStamp([Task Next Execution] -7/24 , 'DD/MM/YYYY hh:mm:ss')

Now, How can I calculate the Frequency field (round to 1 hr) that basically shows the difference between Last Reload and Next Execution?

Thanks

3 Replies
abhijitnalekar
Specialist II
Specialist II

Hi @jpjust,

 

Please try below expression.

date(time(round( interval([New Date]-[Old Date],'hh:mm'),maketime(0,30))),'HH') &' Hr'

 

Hope you are looking the same result. 

 

Regards,
Abhijit
keep Qliking...
Help users find answers! Don't forget to mark a solution that worked for you!
stevejoyce
Specialist II
Specialist II

First you need to make sure both are loading as timestamps.  then you can subtract and use Interval() to format as needed.


testdata:
load
[Task Name],
timestamp#([Last Reload], 'YYYY-MM-DD hh:mm:ss') as LastReload,
timestamp#([Next Execution], 'DD/MM/YYYY hh:mm:ss') as NextExecution
;

load * inline
[
Task Name, Last Reload, Next Execution, Frequency

Task A, 2021-10-13 06:55:27, 13/10/2021 07:55:20, 1 Hr]
;

 

expression:

interval(NextExecution-LastReload, 'hh:mm')

jpjust
Specialist
Specialist
Author

Thanks Abhijit.

It sort of worked but the output is wrong for the below. (Instead of 1 hr, it output as 23 hr)

Task Name         Last Reload                                             Next Execution                                Frequency

Task A                    2021-10-13 06:55:27                            13/10/2021 07:55:20                       23 Hr

Below is my expression for the field, frequency.

date(time(round( interval(Max(LogTimeStamp))- TimeStamp([Task Next Execution] -7/24,'hh:mm'),maketime(0,30))),'HH') &' Hr'