Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hi AllI have a column in a table that is of date time format 2006-09-05 14:33:32.0772006-02-24 16:14:09.8532006-02-24 16:14:09.9002006-02-24 16:14:09.9132005-10-12 10:07:50.513need to break it down to 2 parts for a sql querie the two parts areyyyymmdd and HHMISSI need to tweak the following but can not think of something at present brain drain or brain in drain not sure but any help would be appreciated.select convert(char (10),dateprocessed,112),convert(char (10),dateprocessed,108)from tablename
Thank you very very much replace lol now i think of it i used this command last year..
jsmith8858
Dr. Cross Join
7423 Posts
Posted - 2007-04-02 : 21:16:44
There is a DateOnly() and TimeOnly() function here that you can use:http://weblogs.sqlteam.com/jeffs/archive/2007/01/02/56079.aspxUsing convert() returns VARCHAR data, not datetime data, which will not sort or compare as you might expect, and you cannot use Date functions or client formatting on it. It is best to keep your data in the proper datatypes and do the formatting at your front-end.- Jeffhttp://weblogs.sqlteam.com/JeffS