Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 first day of previous quarter

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2010-02-10 : 10:22:20
This is how I work out the first day of quarter:
declare @FirstDayOfQuarter smalldatetime
declare @FirstDayOfPreviousQuarter smalldatetime

set @FirstDayOfQuarter = DATEADD(qq,DATEDIFF(qq,0,GETDATE()),0)

Do you know how to work out the first day of the previous quarter based on my variable above (@FirstDayOfQuarter)?
set @FirstDayOfPreviousQuarter =

Thanks

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2010-02-10 : 10:25:14
It is
set @FirstDayOfPreviousQuarter = DATEADD(qq, -1, @FirstDayOfQuarter)

Thanks anyway
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-10 : 10:29:29
or

DATEADD(qq,DATEDIFF(qq,0,GETDATE())-1,0)

------------------------------------------------------------------------------------------------------
SQL Server MVP
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2010-02-10 : 12:09:52
ok, thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-10 : 12:15:19
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
Go to Top of Page
   

- Advertisement -