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

comparing two dates

Status
Not open for further replies.

camy123

Programmer
Mar 5, 2004
171
0
0
GB
guys justa quickie here..... how can i compare to dates to find out which one is the most recent
using datediff etc ..
cheers guys
 
Code:
DECLARE @date1 datetime,
	@date2 datetime

SET @date1 = '20050501'
SET @date2 = '20050505'

SELECT CASE WHEN @date1 > @date2 THEN @date1 ELSE @date2 END AS MaxDate

--James
 
cheers i was woinderinfg iff there was a datediff version but i suppose that wouldbe much longer.. thank you .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top