Date difference

forum.centura.team.developer (2000-2005) & forum.sqlwindows (2000-2005)
NewsgroupServer
Robot
Robot
Posts: 118939
Joined: 24 Feb 2017, 12:00
Location: World wide

Date difference

Post by NewsgroupServer » 25 Feb 2005, 15:26

 Posted by:  exinger 

I'm using "Select DateTime_Start, DateTime_End,
@TIMEVALUE(DateTime_End-DateTime_Start)"
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
hhhh:mm:ss")
but I get 30 01:10:10

Any suggestions?

Thanks
Maria Exinger

NewsgroupServer
Robot
Robot
Posts: 118939
Joined: 24 Feb 2017, 12:00
Location: World wide

Date difference

Post by NewsgroupServer » 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
number.

NewsgroupServer
Robot
Robot
Posts: 118939
Joined: 24 Feb 2017, 12:00
Location: World wide

Date difference

Post by NewsgroupServer » 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) )

NewsgroupServer
Robot
Robot
Posts: 118939
Joined: 24 Feb 2017, 12:00
Location: World wide

Date difference

Post by NewsgroupServer » 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

NewsgroupServer
Robot
Robot
Posts: 118939
Joined: 24 Feb 2017, 12:00
Location: World wide

Date difference

Post by NewsgroupServer » 11 Mar 2005, 09:05

 Posted by:  one 

Hi,

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.

~ONE~

Return to “forum.sqlwindows”

Who is online

Users browsing this forum: Ccbot [Crawler] and 0 guests