I have a column which has data as such: 2014-08-15 15:11:00
I want to run a select on this column and end up with this: 20140815151100
Basically YYYYMMDDhhmmss.
I tried to do a CAST() and CONVERT() to VARCHAR() and then remove the dashes & colons but when I do that, I end up with this: Aug 15 2014 3:11PM
And that's not what I want. Can someone give me a hand?
In SQL Server 2012 or later you can use the Format() function to get this result:
Select Format(YourColumn, N'yyyyMMddHHmmss')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With