You can translate the question and the replies:

Subtracting two timestamps in Denodo

Hi Support Is it possible to subtract two timestamps in Denodo to get the Day/Hour/Minute/Second difference between the two fields? I don't see a function for it and was having troubles breaking it out with 'get' commands. Thanks!
user
07-09-2016 12:25:38 -0400
code

3 Answers

Hi, If I would need to substract different date attributes I would use vql functions like getday(date), gethour(date), getminute(date), getsecond(date)... as they return long values you could substract them without any problem. I used a vql query to substract the days and the hours from two dates because I needed to know how many days and hours were between those dates: *SELECT mytable."ID", mytable."ENDDATE" - mytable."INITDATE" as "daysdifference", (gethour( mytable."ENDDATE") - gethour( mytable."INITDATE")) as "hoursdifference" FROM mytable;* I think that you could do something similar if you need to get the time difference. You could take a look into the "*Advanced VQL guide*". There is more information at the "*Date Processing Functions*" section. Hope this helps!
Denodo Team
09-09-2016 07:11:34 -0400
code
Thanks for the response... but I am not sure that will work. Consider the follwoing start and end times: starttime = 2014-08-13 19:58:34 endtime = 2014-08-13 20:26:58 So if we think of this like a phone call, then we can pretty easily see that it lasted ~28minutes. Using the GET method would produce a 1 hours and -34 minutes becuase its looking just at the parts and not the whole. I am not sure that this would be accurate for a full picture kind of situation. Am I missing something?
user
09-09-2016 09:37:32 -0400
Hi, If you need to know the difference in minutes between two dates I would create a new column to get the hours, multiply those hours by 60 and then sum the minutes difference between those dates and the hours in minutes. In your example: *1 hour = 60 minutes* **=>** *60 + (-32) = 28 minutes* Hope this helps!
Denodo Team
12-09-2016 04:20:06 -0400
code
You must sign in to add an answer. If you do not have an account, you can register here