-
Notifications
You must be signed in to change notification settings - Fork 1
/
date_tsql.sql
21 lines (19 loc) · 1.06 KB
/
date_tsql.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---https://www.mssqltips.com/sqlservertip/1145/date-and-time-conversions-using-sql-server/
SELECT CONVERT(DATE, GETDATE())
SELECT CONVERT(VARCHAR(19),GETDATE())
SELECT CONVERT(VARCHAR(10),GETDATE(),10)
SELECT CONVERT(VARCHAR(10),GETDATE(),110)
SELECT CONVERT(VARCHAR(11),GETDATE(),6)
SELECT CONVERT(VARCHAR(11),GETDATE(),106)
SELECT CONVERT(VARCHAR(24),GETDATE(),113)
SELECT REPLACE(CONVERT(CHAR(11), GETDATE(), 106),' ','-')
SELECT CONVERT(DECIMAL(18,4),COALESCE((VD.CrAmount),0))
SELECT DATENAME(MONTH , DATEADD( MONTH , 04 , 0 ) - 1 )
SELECT LEFT(DATENAME(MONTH, GETDATE()),3) AS [Short Month Name]
, LEFT(DATENAME(WEEKDAY, GETDATE()),3) AS [Short Weekday Name]
, LEFT((DATENAME( MONTH , DATEADD( MONTH , 04 , 0 ) - 1 )),3)
, FORMAT(GETDATE(),'MMM') AS [Short Month Name]
, FORMAT(GETDATE(),'ddd') AS [Short Weekday Name]
SELECT CONVERT(DATE, GETDATE()) AS [DATE], CONVERT(VARCHAR(8), CONVERT(TIME, GETDATE())) AS [TIME]
--January 2020
SELECT DATENAME(MONTH , DATEADD( MONTH , MONTH(GETDATE()) , 0 ) - 1 ) + ' ' + CAST(YEAR(GETDATE()) AS VARCHAR)