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

Time & Date

Status
Not open for further replies.

xxtravel

Programmer
Aug 24, 2002
22
0
0
MV
I am trying to create a program which can calculate some date & time for peak hour & off peak hour for a car parking place from the date & time it get parked & leave.

the peak hours is 08:00 - 13:59 hrs & off peak hours is 14:00 - 07:59 hrs.

Charges are applied for every 03 hrs block starting from the parked hour, for peak hours charge is 100.00 US$ per 03 hr block & off peak 50.00 US$ per 03 hr block

if a car is parked on 06/04/04 at 10:03 hrs & it leaves on 15/04/04 at 13:25 hrs what will be its total peak hours & off peak hours?

for example: on 06/04/04 from 10:03 hrs until 07/04/04 10:30 hrs, it will be a 24 round and there will be 03 peak hr bock & 05 off peak hr bock.

i hope you will understand now what i am trying to explain.

i need this program to find out the total peak hours & off peak hours during the entire period the car is parked.

Can anyone help.

chao, xtravel

My Site:
 
To get you started take a look at the Datediff function.

"Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'."
 
The logic is the fun part.

Check if the start time begins in peak hours or off peak hours. Then add to a running total the datediff of that time and the end of that period or end time, which ever comes first. Next just reset your new start time to the beginning of the next period and continue adding to the running totals. Keep doing this until you reach the end time.

Makes sense?

"Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'."
 
xxtravel,
DrJavaJoe's suggestion seems pretty clear. If you have a specific problem with code, to get more detailed help you probably need to post the relevant section of your code.

This isn't actually a code-swap type of forum. The suggested guidelines are given in faq222-2244 paragraphs 8,9 & 10

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top