July 31, 2002 at 5:06 pm
I am new to T-SQL and need help writing a statement. I have a table that that has multiple dates for one person. ie: 01/14/2002,01/08/1999,01/20/2000,01/30/2001. I need to get the most recent date which would be 1/14/2002. When I use the MAX I get the 1/30/2001. How do I get the most recent year?
Thanks
July 31, 2002 at 5:45 pm
max should give you the max date. Are these character values?
you can do max(datepart(year, value))
Steve Jones
July 31, 2002 at 7:33 pm
Thanks, that gives me the year but I also require the month and day...
August 1, 2002 at 12:36 am
you seem to be storing the dates as character values . use MAX(CONVERT(Datetime,value))
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply