Date and Time Formating tagged posts

Date and Time Formatting Scripts in Management Studio Query Editor (SQL Server)

Category: SQL Comments: No comments

-- Get date only from datetime - QUICK SYNTAX SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, CURRENT_TIMESTAMP)) -- 2016-10-23 00:00:00.000 ------------ -- SQL Server T-SQL date & datetime formats - Gregorian calendar - Christian calendar -- getdate() / CURRENT_TIMESTAMP(ANSI) returns system date & time in standard format -- SQL datetime formats with century (YYYY or CCYY format)- sql date & time format SELECT convert(varchar, getdate(), 100) -- mon dd yyyy hh:mmAM (or PM) -- Oct 2 2010 11:01AM SELECT convert(varchar, getdate(), 101) -- mm/dd/yyyy - 10/02/2010 SELECT convert(varchar, getdate(), 102) -- yyyy.mm.dd - 2010.10.02 SELECT convert(varchar, getdate(), 103) -- dd/mm/yyyy SELECT convert(varchar, getdate(), 104) -- dd.mm.yyyy SELECT convert(varchar, getdate(), 105) -- dd-mm-yyyyRead More