==================================================================================================== http://www.sql-tutorial.ru/ru/book_tsql_datetime_functions.html GETDATE() CURRENT_TIMESTAMP {fn NOW()} DATEADD(datepart, number, date) -- âîçâðàùàåò çíà÷åíèå òèïà datetime, êîòîðîå ïîëó÷àåòñÿ äîáàâëåíèåì ê äàòå date êîëè÷åñòâà èíòåðâàëîâ òèïà datepart, ðàâíîãî number. select dateadd(hour, -1, getdate()) - ÷àñ íàçàä DATEDIFF(datepart, startdate, enddate) -- âîçâðàùàåò èíòåðâàë âðåìåíè, ïðîøåäøåãî ìåæäó äâóìÿ âðåìåííûìè îòìåòêàìè — startdate è enddate select datediff(Minute, dateadd(hour, -2, getdate()), getdate()) DATEPART(datepart , date) -- âîçâðàùàåò öåëîå ÷èñëî, ïðåäñòàâëÿþùåå ñîáîé óêàçàííóþ àðãóìåíòîì datepart ÷àñòü çàäàííîé âòîðûì àðãóìåíòîì äàòû (date). select datepart(hour, getdate()) DATENAME(datepart, date) -- âîçâðàùàåò ñèìâîëüíîå ïðåäñòàâëåíèå ñîñòàâëÿþùåé (datepart) óêàçàííîé äàòû (date). -- Àðãóìåíò, îïðåäåëÿþùèé ñîñòàâëÿþùóþ äàòû, ìîæåò ïðèíèìàòü îäíî èç çíà÷åíèé, ïåðå÷èñëåííûõ â òàáëèöå â íà÷àëå ýòîé ãëàâû. select datename(hour, getdate()) Datepart Äîïóñòèìûå ñîêðàùåíèÿ Year — ãîä yy, yyyy Quarter — êâàðòàë qq, q Month — ìåñÿö mm, m Dayofyear — äåíü ãîäà dy, y Day — äåíü dd, d Week — íåäåëÿ wk, ww Hour — ÷àñ hh Minute — ìèíóòà mi, n Second — ñåêóíäà ss, s Millisecond - ìèëëèñåêóíäà ms