1. Get month names with month numbers: In this query we will learn about How to get all month names with month number in SQL Server . I have used this query to bind my dropdownlist with month name and month number. 1 2 3 4 5 6 7 8 9 10 11 12 ;WITH months(MonthNumber) AS ( SELECT 0 UNION ALL SELECT MonthNumber+1 FROM months WHERE MonthNumber < 12 ) SELECT DATENAME(MONTH,DATEADD(MONTH,-MonthNumber,GETDATE())) AS [MonthName],Datepart(MONTH,DATEADD(MONTH,-MonthNumber,GETDATE())) AS MonthNumber FROM months ORDER BY Datepart(MONTH,DATEADD(MONTH,-MonthNumber,GETDATE())) ; 2. Get name of current month: In this query we will learn about How to get name of current month in SQL Server . 1 select DATENAME(MONTH, GETDATE()) AS CurrentMonth 3. Get name of day: In this query we will learn about How to get name of day in SQL Server . 1 select DATENAME(WEEKDAY, GETDATE()) AS TodayI
Great informative post and i really likes your information, most of the peoples are likes your blog because its having the good knowledge. thanks for your good informative post.website hosting india
ReplyDelete