Beginning and Ending DATE of a Quarter

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

    Beginning and Ending DATE of a Quarter


    First Day of the QUARTER

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


    Question: How do I get the last DAY of the QUARTER?

    For example: 1st Quarter is 01/01/2008 to 03/31/2008.

    I am having difficulties finding the last day of the quarter.

    Thanks in advance.
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Originally posted by benchpolo

    First Day of the QUARTER

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


    Question: How do I get the last DAY of the QUARTER?

    For example: 1st Quarter is 01/01/2008 to 03/31/2008.

    I am having difficulties finding the last day of the quarter.

    Thanks in advance.
    Get the first day of the next quarter then subtract by one day....

    or

    Add three months then subtract one day.

    -- CK

    Comment

    • hrothenb
      New Member
      • Mar 2012
      • 2

      #3
      SELECT DATEADD(QQ, DATEDIFF(QQ,0,G ETDATE())-1,0) as [Start Of Last Quarter]
      ,DATEADD(s,-1,DATEADD(QQ, DATEDIFF(QQ,0,G ETDATE()),0)) as [End Of Last Quarter]

      SELECT DATEADD(QQ, DATEDIFF(QQ,0,G ETDATE()),0) as [Start Of Quarter]
      ,DATEADD(s,-1,DATEADD(QQ, DATEDIFF(QQ,0,G ETDATE())+1,0)) as [End Of Quarter]

      Comment

      Working...