dbTalk Databases Forums  

Calculate Time Off

microsoft.public.sqlserver.programming microsoft.public.sqlserver.programming


Discuss Calculate Time Off in the microsoft.public.sqlserver.programming forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Woo Mun Foong
 
Posts: n/a

Default Calculate Time Off - 03-06-2006 , 07:15 AM






Hi,

I need a query that can return the total time off between 2 dates.
I have a table call tblTimeOff which has the following fields
StartTimeOff, Interval (minute), Weekend
Sample data for tblTimeOff:-
10.00AM, 15, 0 - Timeoff period 10.00am to 10.15am on Weekday
12.00pm, 60, 0 - Timeoff period 12.00pm to 1.00pm on Weekday
15.00pm,15, 0 - - Timeoff period 3.00pm to 3.15pm on Weekday
10.30AM, 15, 1 - Timeoff period 10.30am to 10.45am on Weekend
12.30pm, 60, 1 - Timeoff period 12.30pm to 1.30pm on Weekend

Saturday and Sunday are considered as Weekend.
Mon - Fri are Weekend

I need a query when user provide me with 2 date:-
Condition 1:
--------------
Start :- 2nd March 8.30am
End :- 4th March 11.00am
The result for total time off should be:- 195 mins
2nd March - 15+60+15, 3rd March - 15+60+15, 4th March (weekend) - 15

Condition 2:
--------------
Start :- 2nd March 8.30am
End :- 2nd March 5.00pm
The result for total time off should be:- 90 mins
2nd March - 15+60+15

Anyone help ?

Thank You,
mfwoo



Reply With Quote
  #2  
Old   
Jim Underwood
 
Posts: n/a

Default Re: Calculate Time Off - 03-06-2006 , 07:41 AM






Where are your dates stored in your tables?

Posting the full DDL may help.
http://www.aspfaq.com/etiquette.asp?id=5006

"Woo Mun Foong" <mfwoo (AT) yahoo (DOT) com> wrote

Quote:
Hi,

I need a query that can return the total time off between 2 dates.
I have a table call tblTimeOff which has the following fields
StartTimeOff, Interval (minute), Weekend
Sample data for tblTimeOff:-
10.00AM, 15, 0 - Timeoff period 10.00am to 10.15am on Weekday
12.00pm, 60, 0 - Timeoff period 12.00pm to 1.00pm on Weekday
15.00pm,15, 0 - - Timeoff period 3.00pm to 3.15pm on Weekday
10.30AM, 15, 1 - Timeoff period 10.30am to 10.45am on Weekend
12.30pm, 60, 1 - Timeoff period 12.30pm to 1.30pm on Weekend

Saturday and Sunday are considered as Weekend.
Mon - Fri are Weekend

I need a query when user provide me with 2 date:-
Condition 1:
--------------
Start :- 2nd March 8.30am
End :- 4th March 11.00am
The result for total time off should be:- 195 mins
2nd March - 15+60+15, 3rd March - 15+60+15, 4th March (weekend) - 15

Condition 2:
--------------
Start :- 2nd March 8.30am
End :- 2nd March 5.00pm
The result for total time off should be:- 90 mins
2nd March - 15+60+15

Anyone help ?

Thank You,
mfwoo





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.