PDA

View Full Version : Using MAX in SQL statement


troy
06-18-2003, 06:23 PM
I have a SQL statement that uses MAX and MIN in a date feild. When the results are returned as long as the two dates are in the same year, I'm ok when this isnt the case it seems that the function reads the string left to right and puts 01/01/03 before 12/01/02

thanks in advance

Kodo
06-18-2003, 07:37 PM
can you post your SQL statement and a result sample?

troy
06-18-2003, 07:40 PM
think Ive fixed it...for now

troy
06-18-2003, 08:22 PM
Since I hate when I look at posts with no resolution.

MIN(CONVERT(VARCHAR(20), usage_date, 101)) date_first_view,

I removed the (CONVERT(VARCHAR(20), usage_date, 101)) from within the sql statement and replaced it with (usage_date)


MIN(usage_date) date_first_view,