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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DatePart Function 1

Status
Not open for further replies.

MickDub

Programmer
Apr 19, 2006
9
IE
i am using the DatePart function to do the following

"Sum(CASE DATEPART(dw,pdate) When 1 Then 1 ELSE 0 END) AS Sunday"

But would liek break sunday into morning and evening

have tried (Ftiem been the tiem field on my table)

"Sum(CASE DATEPART(dw,pdate) When 1 And Ftime between '01:00:00' And '11:59:00' Then 1 ELSE 0 END) AS SundayMorning"

But get errors is it possible to do this using the DatePart fucntion or is there another way around this

Kind Regards,
Mick
 
may be this:

"Sum(CASE WHEN [red]DATEPART(dw,pdate)=1 AND Ftime between '01:00:00' And '11:59:00'[/red] Then 1 ELSE 0 END) AS SundayMorning"

-DNG
 
Super stuff DNG,spot on, Thanks a million
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top