Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quarter

Status
Not open for further replies.

mjd3000

Programmer
Apr 11, 2009
136
GB
Is there a keyword that you can use in SQL Reporting Services that allows you to write queries based upon the quarter of the year that a particular date field is in?
 
I use datepart(Quarter, <datefield>) in the sql

so
Code:
select datepart(Quarter, getdate()), getdate()
should get you the quarter number of today's date...

make sense?
 
Thanks....how would I get Year, Month, Week and Day? Would it be the same as above but with the 'Year', 'Month', 'Week' and 'Day' replacing 'Quarter'?

Does this give me the actual Month and Day names, rather than the numbers?
 
cool thing about Google is that you can find this stuff pretty quickly.

I have been known to translate things in the sql. seems like I had a fancier way some place, but this should get you a start
Code:
SELECT DATEPART(WeekDay, getdate()) AS WeekDayPart, 
   DayOfTheWeek =
      CASE 
        WHEN DATEPART(WeekDay, getdate()) = 1 THEN 'Sunday'
        WHEN DATEPART(WeekDay, getdate()) = 2 THEN 'Monday'
        WHEN DATEPART(WeekDay, getdate()) = 3 THEN 'Tuesday'
        WHEN DATEPART(WeekDay, getdate()) = 4 THEN 'Wednesday'
        WHEN DATEPART(WeekDay, getdate()) = 5 THEN 'Thursday'
        WHEN DATEPART(WeekDay, getdate()) = 6 THEN 'Friday'
        WHEN DATEPART(WeekDay, getdate()) = 7 THEN 'Saturday'
        ELSE 'wtfo'
      END
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top