Thanks a lot. You seem to always come up with a solution that hits right at the problem and fixes it. Thanks a lot for all your help. Regards, Harpreet ----- Original Message ----- From: "Svensson, B.A.T. (HKG)" <B.A.T.Svensson@xxxxxxx> To: "''Php-Windows ' '" <php-windows@xxxxxxxxxxxxx> Sent: Tuesday, March 23, 2004 3:10 PM Subject: RE: Convert string to date > With MS SQL server you can do something like this: > > select convert(char(10), expiration, 101) as <something> > ... > order by convert(varchar, expiration, 112) > > 112 gives the date format as "yyyymmdd", and that should > solve your problem. > > -----Original Message----- > From: Harpreet K. Singh > To: 'Php-Windows ' > Sent: 23-3-2004 19:06 > Subject: Convert string to date > > I have a report that has an expiration field > > I want to sort by expiration but when clicked it sorts alphanumerically > and shows january 01 before march 03 no matter what the year. > > If i do select expiration and sort it works fine but if i say > select [expiration]=convert(char(10), expiration, 101) it sorts alpha > numerically. > > I want to display in the format above but sort by date > > Please help > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php