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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Difference between times

Status
Not open for further replies.

VDavid

Programmer
Sep 14, 2003
118
VE
Hi,
I want to get the difference between two times, the data is like this:

Id StarTime EndTime
1 11:55:27.945 null
2 11:55:34.765 12:55:57.766
3 12:56:19.047 14:59:29.703
4 00:03:30.842 null
5 02:20:44.165 15:08:32.579
6 15:25:58.247 16:35:13.895

what i want is to get a 4 column TOTAL like:

Id TOTAL
1 (blank , because EndTime is null)
2 01:00
3 02:03
4 (blank , because EndTime is null)
5 12:48
6 01:10

I'm using Sybase SQL Anywhere 5.5
Columns StarTime and EndTime are TIME

Is there a way of doing this in a single SELECT.

Any help will be appreciate.

Thanks,
David.

P.S. I'm new in Tek-Tips, should I post this here or in another forum.
 
The ANSI/ISO solution is:

select Id, (EndTime - StarTime) hour to minute as TOTAL from t


/Jarl
 
Thanks Jarl, but I've tried that and doesnt work, I guess is the Sybase implementation of time.
The closer I've get is using the datediff function, but the result isnt in time format instead in integers. I've tried doing the conversions and formatting myself but i always get some extra or less minutes than it should be. I'll continue trying. There should be a way.

David.
 
For a Sybase answer goto
thread187-660184
Thanks all.

David.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top