Derive Quarter Begin Date

Posted on 2006-05-11
Last Modified: 2012-06-22
Does anyone have some simple code to derive the quarter begin date
from GetDate()?

Question by:JeffDrummond
    LVL 142

    Expert Comment

    by:Guy Hengel [angelIII / a3]
    by quarter you mean 1.jan, 1.apr, 1.jul, 1.oct ?
    LVL 142

    Accepted Solution

    first of month:
    select dateadd(day, 1-datepart(day, getdate()), getdate())

    first of quarter:
    select dateadd( month,  1-datepart(month, getdate()) % 3   , dateadd(day, 1-datepart(day, getdate()), getdate()))
    LVL 34

    Expert Comment

    by:Brian Crowe
    DECLARE @QBegin datetime

    SET @QBegin = CONVERT(varchar, GetDate(), 101)
    SET @QBegin = DATEADD(month, -(MONTH(@QBegin) % 3) + 1, @QBegin)
    SET @QBegin = DATEADD(day, -DAY(@QBegin) + 1, @QBegin)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Performance is the key factor for any successful data integration project, knowing the type of transformation that you’re using is the first step on optimizing the SSIS flow performance, by utilizing the correct transformation or the design alternat…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
    Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now