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.
| Author |
Topic |
|
shanmugaraj
Posting Yak Master
219 Posts |
Posted - 2012-09-11 : 01:44:47
|
| Hi,Need Convert Function convert the date format of an field as belowSelect OrderDate from TableOrderDate : 2012-08-21 17:45:24.557Expected Data : 20120821 174524.5570YYYYMMDD HH24MISS.MS4 whereYYYY - YearMM - MonthDD - DayHH24 - Hours in the 24hr formatMI - MinutesSS - SecondsMS4 - Milliseconds which is rounded to 4 decimal places-Thanks in advanceRaj |
|
|
mani_1234
Starting Member
24 Posts |
Posted - 2012-09-11 : 03:12:52
|
| select replace(replace(CONVERT(varchar(23),getdate(),121),'-',''),':','') |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2012-09-11 : 08:59:04
|
| [code]select DT=right(replace(replace(convert(varchar(30),convert(datetime2(4),'2012-08-21 17:45:24.557'),121),'-',''),':',''),21)[/code]Results:[code]DT---------------------20120821 174524.5570[/code]CODO ERGO SUM |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2012-09-13 : 03:19:56
|
| Where do you want to show data? If you use front end application, do formation there.MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|