datetime
, the current language is considered. The following cast would not work if the language was set to german
, for example. set language english select cast('2018-08-28' as datetime)
datepart
can be used to extract parts of a date, for example select datepart(hour, sysdatetime());
convert
: select convert(varchar(23), getdate (), 126); -- -- 2019-06-22T18:01:49.820 select convert(varchar(27), sysutcdatetime(), 127); -- -- 2019-06-22T16:01:49.8205525
datename()
function.