It would be great to have a function that calculate the difference between 2 dates
For my part, I need to know the number of day between 2 datetime, without taking hours/minutes in account. ie 26/12/212 15:12:56 and 22/12/212 05:01:32 would give 4 days. I'm just taking the difference between the date.
In SQL I would use something like that (postgres):
date_part('day', date_trunc('day', end) - date_trunc('day', start))
in MSSQL and Sybase there is the datediff function:
datediff(dd, start, end)
in MySQL it woulf be:
The text was updated successfully, but these errors were encountered:
You use the
Thanks for the new function.
For my part, I really need the date_trunc part. Or anyway to convert a datetime to a date.
Because if I have date1= 01/01/2013 15:00 and date2 = 02/01/2013 10:00 I need the datediff (date2 - date1) to be 1 day and not 19 hours...
Perhaps am I missing something but I didn't find a way to convert my datetime (DateTimePath<java.sql.Timestamp>) to a date (DatePath<java.sql.Date>) element.
I think it should not be in the datediff function as it works correctly but perhaps in a date_trunc function or in casttodate function.