I am trying to get the getdate in the YYYYMMDDHHMM format.
I wrote a query like this:
SELECT CAST(CONVERT(VARCHAR, GETDATE(), 112) AS VARCHAR)+CONVERT(VARCHAR,DATEPART(hh,GETDATE()))
+CONVERT(VARCHAR,DATEPART(minute,GETDATE()))
It's giving me correct output but is there a simple way of doing it?
Don't know how much "simpler" this is, but:
SELECT CONVERT(CHAR(8), GETDATE(), 112)
+ REPLACE(CONVERT(CHAR(5), GETDATE(), 108), ':', '')
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