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.
| Author |
Topic |
|
himi
Starting Member
3 Posts |
Posted - 2009-03-06 : 12:48:53
|
| Hello all,I have a simple database of tickets. Once ticket is submitted there is DATETIME saved. I need to count time of the ticket but during business hours only, let's say 9-17 and on week days only. Also clock can be stopped when ticket is in "pending" status.I found another topic here on forums but it is not finished and did not work for me.I can count time on week days only:SELECT id FROM tickets WHERE DATE_FORMAT(submitted, '%W') NOT IN ('Saturday','Sunday')..but those business hours are mystery for me.Anyone have any ideas?Many thanks in advance!! |
|
|
guptam
Posting Yak Master
161 Posts |
Posted - 2009-03-06 : 13:06:11
|
| How about ..SELECT id FROM TICKETS WHERE (DATEPART(WEEKDAY,Submitted) Between 2 AND 6) AND (DATEPART(HOUR,Submitted) Between 9 AND 17)?-- Mohit K. GuptaB.Sc. CS, Minor JapaneseMCITP: Database AdministratorMCTS: SQL Server 2005http://sqllearnings.blogspot.com/ |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-07 : 13:33:01
|
| are you using sql server? |
 |
|
|
himi
Starting Member
3 Posts |
Posted - 2009-03-09 : 04:30:56
|
| Hello, sorry for late reply. Thanks. I'm using MySQL and when I try what guptam suggested it says "FUNCTION DATEPART does not exist". |
 |
|
|
ddramireddy
Yak Posting Veteran
81 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-03-09 : 08:49:20
|
quote: Originally posted by himi Hello, sorry for late reply. Thanks. I'm using MySQL and when I try what guptam suggested it says "FUNCTION DATEPART does not exist".
Post your question at mysql forums such as www.mysql.comMadhivananFailing to plan is Planning to fail |
 |
|
|
himi
Starting Member
3 Posts |
Posted - 2009-03-09 : 10:55:22
|
| Thanks & Sorry! |
 |
|
|
guptam
Posting Yak Master
161 Posts |
Posted - 2009-03-09 : 14:12:03
|
| heh yaa my bad that was SQL Server version hehe .. Good luck finding answer :) I haven't touched MySQL for over 6 years can't help there heh.-- Mohit K. GuptaB.Sc. CS, Minor JapaneseMCITP: Database AdministratorMCTS: SQL Server 2005http://sqllearnings.blogspot.com/ |
 |
|
|
|
|
|
|
|