Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
sql_server 217
t-sql 211
tsql 116
sqlserver 96
BRH 78
#SQLServer 66
#TSQL 56
SQL Server 34
function 11
SSMS 9

Archive · View All
August 2007 17
August 2010 8
June 2012 7
June 2011 7
November 2007 7
August 2012 6
May 2012 6
November 2011 6
August 2011 6
October 2011 6

Madhivanan's TSQL Blog

List the Name of the Months Between Date Ranges

Dec 21 2014 12:00AM by Madhivanan   

Pinal Dave, Blogger,Speaker and my friend, posted about SQL SERVER – List the Name of the Months Between Date Ranges – Part 2 where he showed a method to list of all the months between two date ranges. This is one more method

DECLARE @DateStart DATETIME = '2014-07-17' -- 2014 July
DECLARE @DateEnd DATETIME = '2015-07-08'; -- 2015 July


select 
	year(dates) as Year, 
	month(dates) as MontNumber,
	left(convert(char(10),dates,101),2) as MonthNumberLeadingZero,
	datename(month,dates) as MonthName
	from
	(
		select dateadd(month,number,@DateStart) as dates from master..spt_values
		where type='p' and number between 0 and datediff(month,@DateStart,@DateEnd)
	) as t 

The result is
Year        MontNumber  MonthNumberLeadingZero MonthName
----------- ----------- ---------------------- ------------------------------
2014        7           07                     July
2014        8           08                     August
2014        9           09                     September
2014        10          10                     October
2014        11          11                     November
2014        12          12                     December
2015        1           01                     January
2015        2           02                     February
2015        3           03                     March
2015        4           04                     April
2015        5           05                     May
2015        6           06                     June
2015        7           07                     July
This is a good exmaple for using a tally/number table. To know more about it read this post from SQL Server MVP and mentor Jeff Moden

Tags: 


Madhivanan
2 · 40% · 13039
2
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

"List the Name of the Months Between Date Ranges" rated 5 out of 5 by 2 readers
List the Name of the Months Between Date Ranges , 5.0 out of 5 based on 2 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]