How to convert datetime to timestamp ?
Timestamp like 'yyyy-mm-dd hh:mm:ss.mss'
I try to format this
format(time_field , 'dd.mm.yyyy hh:mm:ss')
but in the end it turns out '1.43.2019 01:43:03'
How to convert datetime to timestamp ?
Timestamp like 'yyyy-mm-dd hh:mm:ss.mss'
I try to format this
format(time_field , 'dd.mm.yyyy hh:mm:ss')
but in the end it turns out '1.43.2019 01:43:03'
use MM
for month when formatting
SELECT FORMAT(GETDATE(), 'dd.MM.yyyy HH:mm:ss')
use the built in convert function, with a suitable option.
SELECT CONVERT(varchar, getdate(), 21);
You don't actually need to use format()
for this, because the format you want is a "built-in" format for SQL Server's convert()
function:
select convert(varchar(255), timefield, 120)
I'm not a big fan on convert()
and its arcane formatting options. However, options 120 and 121 are pretty much the ones that I know and use.