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

SUBTRACTING two Sybase DATETIME values to get duration

Status
Not open for further replies.

loch

Technical User
Nov 13, 2002
2
US
Hi. Can someone assist a newbie in calculating the length of time (in days) from one date value to another?

For example, I have START_DATE and END_DATE values (both DATETIME datatypes) in a temp table. I want to update the table with a DURATION value. I tried the following:

UPDATE #TEMP1
SET DURATION = (END_DATE - START_DATE)
FROM #TEMP1
WHERE END_DATE IS NOT NULL

However, I'm getting error "Invalid operator for datatype op: SUBTRACT type: DATETIME." I've tried converting the datatype without much luck either.

Much appreciate the feedback.
 
never mind, i found the correct syntax.

UPDATE #TEMP
SET A.DURATION = DATEDIFF(DD, END_DATE, START_DATE)
FROM #TEMP A
WHERE A.END_DATE IS NOT NULL
 
Great - Always better to find out for yourself !
;-) Dickie Bird
Honi soit qui mal y pense
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top