Wednesday, September 26, 2012

Find Current Year Start Date and End Date in SQL?


select  DATEADD(yy, DATEDIFF(yy,0,getdate()), 0)'Start Date ',
DATEADD(dd,-1,DATEADD(yy,0,DATEADD(yy,DATEDIFF(yy,0,getdate())+1,0))) 'End Date'


Output


Start Date                          End Date
2012-01-01 00:00:00.000 2012-12-31 00:00:00.000


Find Current QUARTER Start Date and End Date in SQL

SELECT  DATEADD(qq, DATEDIFF(qq, 0, GETDATE()),  0)'Start Date',DATEADD(qq, DATEDIFF(qq, - 1, GETDATE()), - 1)'End Date'


Output:

Start Date                                 End Date
2012-07-01 00:00:00.000 2012-09-30 00:00:00.000

Monday, September 17, 2012

Set Current Month,Year as a Default Parameter in SSRS

Introduction

                  Set Default value to Parameter  @Year=Year(Now())
                  Set Default value to Parameter @Month=Month(Today)(This gives you integer value of Month 1 to 12) or  =MonthName(Month(Now)) (This gives you the string value like January,February,March etc.)


Please Note that you have to add value in Parameter.