Reputation: 2108
I've been looking for the answer and could not find the exact one satisfying my needs.
I'm looking for the way to convert Datetime
value into YYYY-MM-DD-HHMM
format.
I tried that one:
select CONVERT(varchar(20),GETDATE(), 120) + replace(convert(varchar(5),getdate(),108),':','')
But it did not give me the right results
Is there any practical way to do it?
Upvotes: 4
Views: 27533
Reputation: 2108
This works for me:
select CONVERT(varchar(10),GETDATE(), 20) + '-' + replace(convert(varchar(5),getdate(),108),':','')
I'm not sure if this is efficient or not, though
Upvotes: 0