Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find time difference

Status
Not open for further replies.

marydn

Programmer
Mar 26, 2001
152
US
Hi,

I need to find the differene in time for 2 fields. The table is set up as follows:

Field Name Data Type

UpDate varchar (i.e. 2002-04-01)
UpTime varchar (i.e. 22:50:00)
DownDate varchar (i.e. 2002-04-01)
DownTime Varchar (i.e. 22:45:00)

All I want to get is 5 minutes.

Any help is greatly appreciated.

 
create table Tim(UpDates varchar(30),UpTime varchar(30) ,DownDate varchar(30),DownTime Varchar(30))

insert into Tim select '2002-04-01','22:50:00','2002-04-01','22:45:00'


select 'TimeDifference' = (-1)*datediff(n,convert(datetime,Updates+' '+UpTime),convert(datetime,Downdate+' '+Downtime)) from tim
 
It worked like a charm - Thanks Tim - you made my day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top