Date difference

forum.advanced.programming (1998-2005)

Date difference

Post by exinger » 25 Feb 2005, 15:26

 Posted by:  exinger 

I'm using "Select DateTime_Start, DateTime_End,
but @timevalue returns a wrong number of days (always 30) for the same day
of the date!
A sample:
DateTime_Start=20.02.2005 08:00:00 (european date-> dd.MM)
DateTime_End =20.02.2005 09:10:10
The difference should be 00 01:10:10 (the tablefield is formated "dd
but I get 30 01:10:10

Any suggestions?

Maria Exinger

Fridolin Schwarz

Date difference

Post by Fridolin Schwarz » 28 Feb 2005, 18:56

 Posted by:  Fridolin Schwarz 

I think the problem could be that @TIMEVALUE(...) does not return a day
portion at all and so SqlWindows makes an assumption and guesses a valid day

Jim McNamara

Date difference

Post by Jim McNamara » 28 Feb 2005, 21:25

 Posted by:  Jim McNamara 

Select DateTime_Start, DateTime_End, DateTime_End - DateTime_Start

should do the trick. You can very easily convert the numeric outcome to
days/hours/minutes in your app.

1 second = 1/86400 of a day (or 1/ (24*60*60) )


Date difference

Post by exinger » 01 Mar 2005, 10:03

 Posted by:  exinger 

Thanks @all

the only solution was to calculate the difference
(date2-date1) as number as mentioned by Jim
and then with SalNumberTruncate & SalNumberMod
to build the string hhhh:mm:ss


Date difference

Post by one » 11 Mar 2005, 09:05

 Posted by:  one 


I have a suggestion, why don't return the result to a variable. Then
use SalFmtFormatDateTime(dtVariable, "dd hh:mm:ss") to format the result
in the variable.


Return to “advanced.programming”

Who is online

Users browsing this forum: [Ccbot] and 0 guests