Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / March 2006

Tip: Looking for answers? Try searching our database.

Calculating Time-off period between 2 dates

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Woo Mun Foong - 06 Mar 2006 13:17 GMT
Hi,

I need a function 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 functions 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
William Stacey [MVP] - 06 Mar 2006 15:55 GMT
DateTime d1 = DateTime.Now;

DateTime d2 = d1 + TimeSpan.FromMinutes(15);

TimeSpan ts = d2 - d1;

Console.WriteLine("Total Minutes:" + ts.TotalMinutes);

Signature

William Stacey [MVP]


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.