Solved

determining number of hours between two times

Posted on 2004-03-26
5
227 Views
Last Modified: 2013-12-24
i have the following start date and end date variables in a form:
 
startdatemonth - (values are 1-12)
startdateday - (values are 1-31..depeding upon the month)
startdateyear - (values are 2004 - 2010)
starttimehour - (values are 6, 6.5, 7, 7.5, 8, 8.5, etc.)
starttimeamorpm - (values are am/pm)

ex. 3/26/2004 8.5 am

enddatemonth - (values are 1-12)
enddateday - (values are 1-31..depeding upon the month)
enddateyear - (values are 2004 - 2010)
endtimehour - (values are 6, 6.5, 7, 7.5, 8, 8.5, etc.)
endtimeamorpm - (values are am/pm)

ex. 3/26/2004 5 pm

i basically want to determine the number of hours in between these two dates.

so for above example it should be 8.5 hours (where 8.5 above means 8:30)

how to do this?

0
Comment
Question by:Judy Deo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 17

Expert Comment

by:Tacobell777
ID: 10691659
You need to use dateDiff("h", yourdate1here, yourdate2here)
0
 

Author Comment

by:Judy Deo
ID: 10691868
but in what format should "yourdate1here" and  "yourdate2here" be? will it let me include the time part (i.e 7:30 am) ?
0
 
LVL 17

Assisted Solution

by:Tacobell777
Tacobell777 earned 150 total points
ID: 10692114
yes it will let you include the time, I should have said yourdatetimehere, it needs to be a valid date and time though.
If you look at the CF documentation and look up createdatetime(), it expects variables like so createDateTime(year, month, day, hour, minute, second)
Or string createDateTime("2004", "3", "26", "9", "20", "0")
0
 
LVL 10

Accepted Solution

by:
Mause earned 350 total points
ID: 10698206
Hi

As Tacobell said you can use datediff to get the hours between the 2 dates.
But I gues yor problem is how to get the 8.5 to 8.30 or 20.30??
How do the users fill in the hours? width a textbox or a dropdown?
If its a dropdown its easy it will be:
<select name="starttimehour">
<option value="1,0">1</option>
<option value="'1','30'">1.5</option>
<option value="'2','0'">2</option>
<option value="'2','30'">2.5</option>
.
.
<option value="'13','0'">1</option>
<option value="'13','30'">1.5</option>
.
.
</select>

Then you can use createdatetime(startdateyear, startdatemonth, startdateday, starttimehour, "0")
AND
datediff("h",  createdatetime(startdateyear, startdatemonth, startdateday, starttimehour, "0"),  createdatetime(enddateyear, enddatemonth, enddateday, endtimehour, "0"))
to get the hours between the 2 dates

let us know
Mause
0
 

Author Comment

by:Judy Deo
ID: 10717749
thanks.
i forgot to ask one thing about the DateDiff function. i will ask it another question.
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question