SELECT FORMAT(GETDATE(),'yyyy-MM-dd HH:mm')
SELECT FORMAT(GETDATE(), 'dd-MM-yy')
SELECT FORMAT(GETDATE(), 'MM/dd')
Letter | Note |
yyyy | 4 Digit Year |
MM | 2 Digit Month |
dd | 2 Digit Day |
HH | 2 Digit Hour (24 hour format) |
mm | 2 Digit Minute |
Sources:
https://www.mssqltips.com/sqlservertip/2655/format-sql-server-dates-with-format-function/
Comments