Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to get the max date using the qtr no and year

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2011-10-13 : 12:26:32
How to get the max date using the quarter number and year number.

QtrNum = 4
YearNum = 2010

Thank you very much for the helpful info.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-13 : 12:30:23
do like

DECLARE @QtrNum int,@YearNum int
SELECT @QtrNum=4,@YearNum=2010
SELECT DATEADD(qq,@QtrNum,DATEADD(yy,@yearNum-1900,0))-1 AS MaxDate,DATEADD(qq,@QtrNum-1,DATEADD(yy,@yearNum-1900,0)) AS minDate


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2011-10-13 : 12:38:40
Excellent.....Thank you very much Visakh.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-13 : 12:40:24
wc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -