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 2000 Forums
 SQL Server Development (2000)
 Datetime and retriving quarterly data

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-01-07 : 10:12:30
Nicki writes "I want to know how to retrieve data from a datetime datatype but have it choose only the quarters. It goes by every 30 days and not the quarter from the date specified. I tried using the Datepart....
SELECT datepart(mm,dateadd(QQ,-2,dateadd(MM,-1,max(dateadded))))

What I am trying to do is take the month and from that subtract two quarters but it doesn't seem to understand the quarters.....it is using days and not quarterly data."

Nazim
A custom title

1408 Posts

Posted - 2002-01-07 : 10:52:19
Your Question isnt clear. but still

if what you are trying to say is "You want to substract two quaters from a given date"
then you can do that simply by using dateadd(MM,-6,getdate())





----------------------------
Anything that Doesn't Kills you Makes you Stronger
Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2002-01-07 : 18:45:06
Nazim,

Why subtract 6 months instead of 2 quarters?

Nicki, If you leave out the datepart part, what do you get? And why are you subtracting one month from the max BEFORE you subtract 2 quarters? Could you provide some sample data to illustrate values for dateadded and your desired result?

--------------------------------------------------------------
1000 Posts, Here I come! I wonder what my new title will be...
Go to Top of Page
   

- Advertisement -