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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Mathematics with date.

Hi Experts,

In my script, I have created a field

Interval(num(Date1)-num(Date2),'ss') as Difference

which  gives me the difference between the two dates in seconds.

Using the same field I am writing an Expression:

=Sum(Difference)/3600   

which converts the sum of difference in dates to hrs.

But what I am getting is Num(Sum(Difference))/3600 which is not required.

How to solve this issue.

hic  please see if you can help me on this.

Regards,

Anjali Gupta

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

tresesco wrote:

Interval() formats the timestamp and doesn't change the underlaying value. Try like:

(Date1-Date2)*3600  as Difference

That should be

(Date1 - Date2) * 24 * 60 * 60

or

(Date1 - Date2) * 86400

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

12 Replies
its_anandrjs
Champion III
Champion III

Hi,

Can you provide some small app to demonstrate this issue so it is easy to look out.

Regards,

Anand

tresesco
MVP
MVP

Interval() formats the timestamp and doesn't change the underlaying value. Try like:

(Date1-Date2)*3600  as Difference

Anonymous
Not applicable
Author

How can you sum the dates??

What is the logic by suming the data and converting it into number and then divide by 3600?? It would not give you right data

First convert your date/Time into hours and then divide it by 3600...

Why you are dividing by 3600??

PrashantSangle

Hi,

If you want difference in hours

then directly you can write

interval(date1-date2,'hh')

or

try expression suggested by tresesco

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Not applicable
Author

Balraj I want the difference in seconds so subtracting, and interval gives me the correct thing .

And i am diving it by 3600 to convert its summation into hrs.

Not applicable
Author

Hi,

Getting the interval(date1-date2,'hh') gives the difference in hours.

Suppose the difference between the two is in muinutes then it will return 0. and summation of 0 won't give me the correct required answer.

Anonymous
Not applicable
Author

Ok, got it. My mistake didnot notice 'ss' in your expression.

Try tresesco suggestion.

jonathandienst
Partner - Champion III
Partner - Champion III

tresesco wrote:

Interval() formats the timestamp and doesn't change the underlaying value. Try like:

(Date1-Date2)*3600  as Difference

That should be

(Date1 - Date2) * 24 * 60 * 60

or

(Date1 - Date2) * 86400

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
tresesco
MVP
MVP

Sometimes it happens ! ; being stupid can't be avoided ! But, fortunately there is always someone like you to spot and correct it.