|
-
Jul 19th, 2005, 11:17 AM
#1
Thread Starter
Lively Member
[RESOLVED] DateTime Format in SQL to Get Time Difference
I have two fields in a record
RespStart and RespEnd in a DateTime format...
When I type in 01:AM and 01:05AM into each field respectavley.. the values change to 01:01:00AM and 01:05:00AM
I am trying to grab the total time from Start to End. When I query the table I get this format in the View
RespStart = 1899-12-30 01:01:00.000
RespEnd = 1899-12-30 01:05:00.000
(RespEnd-RespStart) = 1900-01-01 00:00:00.000
Is there a format to grab the Time values and get the difference from that and / or also change the date field to the current date if needed but mainly I want to get the time format to get the time between
RespStart and RespEnd
Thank you,
--the first two SQL are test to see the values put out
(Select RespStart From TBLBAT_ALARMINC Where AlarmTypeID = 1 AND BatchID = m.BatchID AND ModemID = a.ModemID) AS RespStart,
(Select RespEnd From TBLBAT_ALARMINC Where AlarmTypeID = 1 AND BatchID = m.BatchID AND ModemID = a.ModemID) AS RespEnd,
--This should be the value to grab the time used
(Select (RespEnd - RespEnd) From TBLBAT_ALARMINC Where AlarmTypeID = 1 AND BatchID = m.BatchID AND ModemID = a.ModemID) AS RespTime
-
Jul 19th, 2005, 11:28 AM
#2
Re: DateTime Format in SQL to Get Time Difference
Use the DateDiff function... you can specify if you want seconds 's' minutes 'n' hours 'h', days, etc...
Tg
-
Jul 19th, 2005, 11:56 AM
#3
Thread Starter
Lively Member
Re: DateTime Format in SQL to Get Time Difference
I put in
(Select DateDiff(n,RespEnd,RespEnd) From TBLBAT_ALARMINC Where AlarmTypeID = 1 AND BatchID = m.BatchID AND ModemID = a.ModemID) AS RespTime
yet the value returned is Zero...
n being the interval of Minute
the date value still come out 1899-12-30 01:01:00.000 and
1899-12-30 01:05:00.000
with the RespTime (as above) is 0
not sure how to change the date part since it's not December of 1899
but I would like to get the time difference..
Thanks for any imput
-
Jul 19th, 2005, 12:18 PM
#4
Re: DateTime Format in SQL to Get Time Difference
Just like 1-1 will always be 0... so will this: DateDiff(n,RespEnd,RespEnd)
Try DateDiff(n,RespStart,RespEnd) instead....
Tg
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|