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!

Entering Time

Status
Not open for further replies.

AmberO

MIS
Oct 17, 2001
37
0
0
GB
I am creating a page where the user needs to enter a time that will get stored in an access database. I can get it to work fine if I have the user key the time into a text box (and I have the form send the results to database). However, I would rather use drop down boxes for the hour, minute and Am\Pm. Does anyone know how I can get this to work?

Thanks in Advance!
 
Thanks for the response,

I could store the data in three separate columns. If I did that, how would I work with time calculations? (I am going to need to calculate the number of hours between two times).
 
It sounds like you can get as far as entering the times... As far as calculating the time between, you could do this:

Create a query against the table that contains the numbers selected in the form. Then combine the numbers like this:

=[txtHour] & ":" & [txtMinute]

Then you can format that using Format([txtTime],'hh:nn')

The inputs would look like txtHour=3, txtMinute=5
Using =[txtHour] & ":" & [txtMinute] will give you 3:5
Finally, Format([txtTime],'hh:nn') will give you 03:05

That will give you the ability to calculate the time between two entries. I tried it in Access and it worked for me, but I had to play around with it for a while.

Good Luck!
 
A simple way to do it is to create a separate drop down for the hour, minute, AM/PM. Then, in your ASP page, you would combine those three fields before entering them into the date field of your database. For example, in the ASP page:

strTime = Request.Form("hour") & ":" & Request.Form("minute") & " " & Request.Form("ampm")

Then just insert strTime into the time field.

=========================
rollout
=========================
 
Why make the user insert the time? Give the date/time field a default value, so when the user appends or saves the data it suffs the time in.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top