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
 General SQL Server Forums
 New to SQL Server Programming
 SQL Server 2005 will not display date as quarter

Author  Topic 

omojones
Starting Member

5 Posts

Posted - 2011-05-17 : 11:02:50
Afternoon

I am creating date objects for a BO universe (XI If this matters but unlikely), i am just working through everything in SQL first to make sure it's fine but cannot display quarter.

The standard we've had in other universes is the following

Select Month (Convert(datetime,Convert(Nvarchar,(getdate()),103),103))
- displays month and the same with year in front displays year. But i cannot get SQL 2005 to display quarter.

I have tried using all the following
SELECT Quarter(GETDATE())
SELECT datepart(q(GETDATE())
SELECT datepart(qq(GETDATE())
but just get told that quarter / q / qq is not a function.

I've googled pretty heavily and not had much luck, i'm obviously doing something wrong.

Cheers for any future help!
Owen

omojones
Starting Member

5 Posts

Posted - 2011-05-17 : 11:04:13
just thought i'd say i've tried to find this topic or similar on the forums but have failed to find anything relevant either, if someone has a link to something i've missed that would be appreciated.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-05-17 : 11:05:33
SELECT datepart(Quarter,GETDATE())

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

omojones
Starting Member

5 Posts

Posted - 2011-05-17 : 11:10:20
hi there

tried that and still get the following results, here are the 2 queries...
Select DATEPART(quarter(Convert(datetime,Convert(Nvarchar,getdate(),103),103)))
Select DATEPART(quarter(getdate())

here were my responses
Msg 195, Level 15, State 10, Line 1
'quarter' is not a recognized function name.
Msg 195, Level 15, State 10, Line 2
'quarter' is not a recognized function name.
Go to Top of Page

omojones
Starting Member

5 Posts

Posted - 2011-05-17 : 11:19:55
SORRY, that's worked fine, when i used a comma instead of brackets. ie read what you wrote properly.....

Cheers
Go to Top of Page
   

- Advertisement -