MSSQL Date conversion

-- string to date SELECT CONVERT(datetime, '2017-08-25 23:00:02.000', 120); --get date now SELECT GETDATE() -- -10MIN SELECT DATEADD(mi, -10, GETDATE()) -- +2h SELECT DATEADD(hh, 2, GETDATE()) --year, yyyy, yy = Year --quarter, qq, q = Quarter --month, mm, m = month --dayofyear = Day of the year --day, dy, y = Day --week, ww, wk = Week --weekday, dw, w = Weekday --hour, hh = hour --minute, mi, n = Minute --second, ss, s = Second --millisecond, ms = Millisecond

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.