Reputation: 229
Using t-sql string functions
substring(convert(varchar, getdate(), 120),6, 11)
this will return mm-dd hh:mm
But then how do I get datetime format yy-mm-dd hh:mm
?
Thank you so much in advance.
Upvotes: 3
Views: 6598
Reputation: 238296
Well, convert(varchar(25), getdate(), 120)
returns:
1
1234567890123456789
2013-08-08 01:43:49
So change:
substring(..., 6, 11)
To:
substring(..., 3, 14)
And you'll get:
13-08-08 01:43
Upvotes: 1