Derive Quarter Begin Date

Does anyone have some simple code to derive the quarter begin date
from GetDate()?

Who is Participating?
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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()))
Guy Hengel [angelIII / a3]Billing EngineerCommented:
by quarter you mean 1.jan, 1.apr, 1.jul, 1.oct ?
Brian CroweDatabase AdministratorCommented:
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)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.