none
SQL get First Day This Month From Last Year RRS feed

  • Question


  • Someone, please help. I just want to get the First Day of this Month from LAST YEAR. I'm stuck.

    • Edited by pvong123 Tuesday, February 26, 2019 4:17 PM
    Tuesday, February 26, 2019 4:16 PM

Answers

  • You mean this :

    SELECT DATEADD(DAY, 1,EOMONTH(DATEADD(YEAR,-1,GETDATE()),-1))


    Ousama EL HOR

    [If a post helps to resolve your issue, please click the "Mark as Answer"  of that post or click Answered "Vote as helpful"  button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]


     [User Page]     [MSDN Page]     [Blog]     [Linkedin]

    • Marked as answer by pvong123 Tuesday, February 26, 2019 4:44 PM
    Tuesday, February 26, 2019 4:27 PM
  • SELECT 
    DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0) AS FirstDayOfCurrentMonth,
    DATEADD(MONTH, DATEDIFF(MONTH, 0, DATEADD(YEAR, - 1, GETDATE())), 0) AS FirstDayOfCurrentMonthInLastYear;


    A Fan of SSIS, SSRS and SSAS

    • Marked as answer by pvong123 Tuesday, February 26, 2019 4:45 PM
    Tuesday, February 26, 2019 4:37 PM

All replies

  • You mean this :

    SELECT DATEADD(DAY, 1,EOMONTH(DATEADD(YEAR,-1,GETDATE()),-1))


    Ousama EL HOR

    [If a post helps to resolve your issue, please click the "Mark as Answer"  of that post or click Answered "Vote as helpful"  button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]


     [User Page]     [MSDN Page]     [Blog]     [Linkedin]

    • Marked as answer by pvong123 Tuesday, February 26, 2019 4:44 PM
    Tuesday, February 26, 2019 4:27 PM
  • Select dateadd(month,datediff(month,0,getdate())-12,0)

    Tuesday, February 26, 2019 4:33 PM
    Moderator
  • SELECT 
    DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0) AS FirstDayOfCurrentMonth,
    DATEADD(MONTH, DATEDIFF(MONTH, 0, DATEADD(YEAR, - 1, GETDATE())), 0) AS FirstDayOfCurrentMonthInLastYear;


    A Fan of SSIS, SSRS and SSAS

    • Marked as answer by pvong123 Tuesday, February 26, 2019 4:45 PM
    Tuesday, February 26, 2019 4:37 PM