sql functon
-
how the datetime is written in a particular order using sql function?datetime format which i used is Dec 2 2010 9:40:45:000PM Dec 02, 2010 11:59:59:000PM Dec 3 2010 3:45:54:000AM Dec 3 2010 1:24:23:000AM Dec 3 2010 12:15:27:000AM how these datetimes in a correct order?pls help me...:confused:
-
how the datetime is written in a particular order using sql function?datetime format which i used is Dec 2 2010 9:40:45:000PM Dec 02, 2010 11:59:59:000PM Dec 3 2010 3:45:54:000AM Dec 3 2010 1:24:23:000AM Dec 3 2010 12:15:27:000AM how these datetimes in a correct order?pls help me...:confused:
So you have made the most basic error in data storage, you have stored your dates as varchar. You will have trouble until you reformat your data to datetime. Do it NOW! However this may work on those formats
Select *
From Table1
Order by convert(datetime,StupidVarcharDateField)Never underestimate the power of human stupidity RAH
-
how the datetime is written in a particular order using sql function?datetime format which i used is Dec 2 2010 9:40:45:000PM Dec 02, 2010 11:59:59:000PM Dec 3 2010 3:45:54:000AM Dec 3 2010 1:24:23:000AM Dec 3 2010 12:15:27:000AM how these datetimes in a correct order?pls help me...:confused:
convert(datetime,Field) that's it.
Thanks Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
-
So you have made the most basic error in data storage, you have stored your dates as varchar. You will have trouble until you reformat your data to datetime. Do it NOW! However this may work on those formats
Select *
From Table1
Order by convert(datetime,StupidVarcharDateField)Never underestimate the power of human stupidity RAH
Wow. You got my five for figuring out what the OP wanted. I read the post several times and was left scratching my head. :)
Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
-
Wow. You got my five for figuring out what the OP wanted. I read the post several times and was left scratching my head. :)
Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
Chris Meech wrote:
was left scratching my head
Been there many times, thankfully between the lot of us someone generally gets the idea the OP is trying to convey.
Never underestimate the power of human stupidity RAH