Date Calculation Previous Years

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • benchpolo
    New Member
    • Sep 2007
    • 142

    Date Calculation Previous Years

    select DATEADD(yy, DATEDIFF(yy,0,g etdate()), 0)

    Result
    ------------------------------------------------------
    2008-01-01 00:00:00.000

    I have the above select statement in SQL to dispay the 1st day of the year, but i'm not able to figure out how to display previous years, in this case, i want to display 2006?

    Please advise. Many thanks.
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Originally posted by benchpolo
    select DATEADD(yy, DATEDIFF(yy,0,g etdate()), 0)

    Result
    ------------------------------------------------------
    2008-01-01 00:00:00.000

    I have the above select statement in SQL to dispay the 1st day of the year, but i'm not able to figure out how to display previous years, in this case, i want to display 2006?

    Please advise. Many thanks.

    Try

    Code:
    select dateadd(yy,-2,DATEADD(yy, DATEDIFF(yy,0,getdate()), 0))

    Comment

    Working...