Date Function
-
24 มิถุนายน 2554 18:33
Hi--
I have date time value coming like 02/01/10@12:01 AM (yes, there is @ in between). Is there any easy without substring, concatenation to convert this kind of value to a proper data time value in 24hr format?
Thanks--basant
ตอบทั้งหมด
-
25 มิถุนายน 2554 8:49
Try
SELECT CAST(REPLACE('02/01/10@12:01 AM','@',' ') AS DATETIME)
Jeff Wharton
MSysDev (C.Sturt), MDbDsgnMgt (C.Sturt) MCT, MCPD, MCITP, MCDBA
Blog: Mr. Wharty's Ramblings
Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker- ทำเครื่องหมายเป็นคำตอบโดย Alex Feng (SQL)Moderator 1 กรกฎาคม 2554 10:00
-
25 มิถุนายน 2554 19:29
One more addition to Jeff reply --- set dateformatPlease run below query:set dateformat dmySELECT CAST(REPLACE('02/01/10@12:01 AM','@',' ') AS DATETIME)
http://uk.linkedin.com/in/ramjaddu- ทำเครื่องหมายเป็นคำตอบโดย Alex Feng (SQL)Moderator 1 กรกฎาคม 2554 10:00