If you need a time difference in Seconds between 2 time values, you have to
use the MIDNIGHT_SECONDS scalar function:
Values(Midnight_Seconds(Current_time) - Midnight_Seconds('06.00.00'));
If you need the difference between to dates in days, you have to use the
DAYS scalar function:
Values(Days(Current_Date) - Days('2017-08-02'));
If you need the difference between 2 timestamps in any time unit, you have
to use the TIMESTAMPDIFF scalar function, which is a little tricky.
The following example calculates the difference between the current
timestamp and 05.00 am today in minutes.
Values(TimestampDiff(4, Char(Current_Timestamp -
Timestamp('2017-09-14-05.00.00.000000'))));
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
?Train people well enough so they can leave, treat them well enough so they
don't want to.? (Richard Branson)
-----Original Message-----
From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Gad
Miron
Sent: Mittwoch, 13. September 2017 17:40
To: midrange-l@xxxxxxxxxxxx
Subject: RE: RE: SQL timestamps
Thanks Birgitta,
How do I convert it to Minutes or Seconds or hours ?
divide it by what?
I would like to calculate the time diff between two timestamps without using
the cumbersome TIMESTAMPDIFF function
Gad
.
subject: RE: RE: SQL timestamps
What is the data type of the result of a Timestamp1 - Timestamp2 ?
A numeric value representing the difference in the following format:
YYYYMMDDHHMMSS.msmsms
Mit freundlichen Gr??en / Best regards
Birgitta Hauser
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe,
or change list options,
visit:
https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at
https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link:
http://amzn.to/2dEadiD
As an Amazon Associate we earn from qualifying purchases.