select date format in sql server

select date format in sql server

SELECT CONVERT(VARCHAR, GETDATE(), 100)                                            
SELECT CONVERT(VARCHAR, GETDATE(), 101)               
SELECT CONVERT(VARCHAR, GETDATE(), 102)        
SELECT CONVERT(VARCHAR, GETDATE(), 103)
SELECT CONVERT(VARCHAR, GETDATE(), 104)
SELECT CONVERT(VARCHAR, GETDATE(), 105)
SELECT CONVERT(VARCHAR, GETDATE(), 106)
SELECT CONVERT(VARCHAR, GETDATE(), 107)
SELECT CONVERT(VARCHAR, GETDATE(), 108)
SELECT CONVERT(VARCHAR, GETDATE(), 109)                                      
SELECT CONVERT(VARCHAR, GETDATE(), 110)
SELECT CONVERT(VARCHAR, GETDATE(), 111)
SELECT CONVERT(VARCHAR, GETDATE(), 112)
SELECT CONVERT(VARCHAR, GETDATE(), 113)                                          
SELECT CONVERT(VARCHAR, GETDATE(), 114)
SELECT CONVERT(VARCHAR, GETDATE(), 120)
SELECT CONVERT(VARCHAR, GETDATE(), 121)
SELECT CONVERT(VARCHAR, GETDATE(), 126)

For Example.

SELECT COUNT(*) AS CUST, SUBSTRING(CONVERT(VARCHAR(10), CREATEDDATE, 106), 0,7) AS DATE FROM COMPANY 
         WHERE CONVERT(DATE,CREATEDDATE) >= CONVERT(DATE,DATEADD(DAY, -30, GETDATE()))
         GROUP BY CONVERT(DATE,CreatedDate)




ANIL SINGH

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - http://www.code-sample.com and http://www.code-sample.xyz
My Books - Google Amazon and Flipkart Book Store!

You Might Also Like
Post a Comment
www.code-sample.com/. Powered by Blogger.
ASK Questions
SQL Server NodeJs TypeScript JavaScript Angular SQL Server My Book