If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Time formatting question
I have a time field that I want to store hh:mm:ss. I can set the custom
format to 99:00:00 and the user can input the time but no matter what I do the table only displays hh:mm. Thank you. |
#2
|
|||
|
|||
In the table's design view, set the field's Format to Short Time or enter
hh:nn:ss in the Format property. -- Ken Snell MS ACCESS MVP "Wylie C" wrote in message ... I have a time field that I want to store hh:mm:ss. I can set the custom format to 99:00:00 and the user can input the time but no matter what I do the table only displays hh:mm. Thank you. |
#3
|
|||
|
|||
To display the time in hh:mm:ss format when looking at the Table directly,
set the field's format to Long Time in table design view. Sprinks "Wylie C" wrote: I have a time field that I want to store hh:mm:ss. I can set the custom format to 99:00:00 and the user can input the time but no matter what I do the table only displays hh:mm. Thank you. |
#4
|
|||
|
|||
Oops. Sprinks is correct....it's Long Time, not Short Time.
-- Ken Snell MS ACCESS MVP "Ken Snell [MVP]" wrote in message ... In the table's design view, set the field's Format to Short Time or enter hh:nn:ss in the Format property. -- Ken Snell MS ACCESS MVP "Wylie C" wrote in message ... I have a time field that I want to store hh:mm:ss. I can set the custom format to 99:00:00 and the user can input the time but no matter what I do the table only displays hh:mm. Thank you. |
#5
|
|||
|
|||
Thanks both but I am still having problems..
When I set the field format to hh:nn:ss and the input mask to 99:99:00 it seems to display and store the time in hours, minutes and seconds. I have set the properties on the form to match the table but the value returned afte data is entered shows am or pm.... What I need to do is the user enters a starting time and an ending time and I need to calculate the average speed. Below is the code I have been working with. I started with only hours and minutes input from the user and am trying to change to the hh:mm:ss. The code works until I get to the seconds part: Private Sub Time_Exit(Cancel As Integer) Dim MyETime, MyEMinute, MyEhour, MyESeconds, ETotlTime MyETime = Me.Time If [OdometerEnd] = "0" Or [OdometerEnd] = "" Then [Route#].SetFocus Else 'Assign a time MyEhour = Hour(MyETime) 'MyEHour contains hours MyEMinute = Minute(MyETime) 'MyEMinute contains minutes MyESeconds = Seconds(MyTime) 'MyESeconds contains seconds ETotlTime = (MyEhour * 60) + (MyEMinute * 60) + MyESeconds Me!ETAveSpeed = ([Mileage] / ETotlTime) * 360 [RideTime].SetFocus End If End Sub I get the error at the MyESeconds = Debugging MyEtime at line 3 shows hh:mm:ss with am/pm "Ken Snell [MVP]" wrote: Oops. Sprinks is correct....it's Long Time, not Short Time. -- Ken Snell MS ACCESS MVP "Ken Snell [MVP]" wrote in message ... In the table's design view, set the field's Format to Short Time or enter hh:nn:ss in the Format property. -- Ken Snell MS ACCESS MVP "Wylie C" wrote in message ... I have a time field that I want to store hh:mm:ss. I can set the custom format to 99:00:00 and the user can input the time but no matter what I do the table only displays hh:mm. Thank you. |
#6
|
|||
|
|||
If I am reading your question correctly...
You said you want to store a TIME, not a DURATION. They are two different things. TIME is a specific point in time (1 o'clock, January 15). TIME in this case would never be greater than 24:00:00. DURATION is a length of time spent on a task, or time remaining until an event. This could be any number and can be greater than 24 hours. The key here is that this is a NUMBER, not a TIME. Once you do your calculation, you will get the results in elapses seconds and you can do the division to break it out into hours, minutes, and seconds. 1,000 seconds equals 16 minutes, 40 seconds, for example. Hope that helps, Rick B "Wylie C" wrote in message ... Thanks both but I am still having problems.. When I set the field format to hh:nn:ss and the input mask to 99:99:00 it seems to display and store the time in hours, minutes and seconds. I have set the properties on the form to match the table but the value returned afte data is entered shows am or pm.... What I need to do is the user enters a starting time and an ending time and I need to calculate the average speed. Below is the code I have been working with. I started with only hours and minutes input from the user and am trying to change to the hh:mm:ss. The code works until I get to the seconds part: Private Sub Time_Exit(Cancel As Integer) Dim MyETime, MyEMinute, MyEhour, MyESeconds, ETotlTime MyETime = Me.Time If [OdometerEnd] = "0" Or [OdometerEnd] = "" Then [Route#].SetFocus Else 'Assign a time MyEhour = Hour(MyETime) 'MyEHour contains hours MyEMinute = Minute(MyETime) 'MyEMinute contains minutes MyESeconds = Seconds(MyTime) 'MyESeconds contains seconds ETotlTime = (MyEhour * 60) + (MyEMinute * 60) + MyESeconds Me!ETAveSpeed = ([Mileage] / ETotlTime) * 360 [RideTime].SetFocus End If End Sub I get the error at the MyESeconds = Debugging MyEtime at line 3 shows hh:mm:ss with am/pm "Ken Snell [MVP]" wrote: Oops. Sprinks is correct....it's Long Time, not Short Time. -- Ken Snell MS ACCESS MVP "Ken Snell [MVP]" wrote in message ... In the table's design view, set the field's Format to Short Time or enter hh:nn:ss in the Format property. -- Ken Snell MS ACCESS MVP "Wylie C" wrote in message ... I have a time field that I want to store hh:mm:ss. I can set the custom format to 99:00:00 and the user can input the time but no matter what I do the table only displays hh:mm. Thank you. |
#7
|
|||
|
|||
Rick,
I know I should be getting this but I am not. I have changed the field in the table to Number, single. Input mask 99:99:00 and the same on the form. When I run the code, the time stored in the table has no formatting to separate the hrs, min, sec. If I enter 01:00:00 the number the code reads is 10000. How can I store the value in the table as hh:nn:ss? "Rick B" wrote: If I am reading your question correctly... You said you want to store a TIME, not a DURATION. They are two different things. TIME is a specific point in time (1 o'clock, January 15). TIME in this case would never be greater than 24:00:00. DURATION is a length of time spent on a task, or time remaining until an event. This could be any number and can be greater than 24 hours. The key here is that this is a NUMBER, not a TIME. Once you do your calculation, you will get the results in elapses seconds and you can do the division to break it out into hours, minutes, and seconds. 1,000 seconds equals 16 minutes, 40 seconds, for example. Hope that helps, Rick B "Wylie C" wrote in message ... Thanks both but I am still having problems.. When I set the field format to hh:nn:ss and the input mask to 99:99:00 it seems to display and store the time in hours, minutes and seconds. I have set the properties on the form to match the table but the value returned afte data is entered shows am or pm.... What I need to do is the user enters a starting time and an ending time and I need to calculate the average speed. Below is the code I have been working with. I started with only hours and minutes input from the user and am trying to change to the hh:mm:ss. The code works until I get to the seconds part: Private Sub Time_Exit(Cancel As Integer) Dim MyETime, MyEMinute, MyEhour, MyESeconds, ETotlTime MyETime = Me.Time If [OdometerEnd] = "0" Or [OdometerEnd] = "" Then [Route#].SetFocus Else 'Assign a time MyEhour = Hour(MyETime) 'MyEHour contains hours MyEMinute = Minute(MyETime) 'MyEMinute contains minutes MyESeconds = Seconds(MyTime) 'MyESeconds contains seconds ETotlTime = (MyEhour * 60) + (MyEMinute * 60) + MyESeconds Me!ETAveSpeed = ([Mileage] / ETotlTime) * 360 [RideTime].SetFocus End If End Sub I get the error at the MyESeconds = Debugging MyEtime at line 3 shows hh:mm:ss with am/pm "Ken Snell [MVP]" wrote: Oops. Sprinks is correct....it's Long Time, not Short Time. -- Ken Snell MS ACCESS MVP "Ken Snell [MVP]" wrote in message ... In the table's design view, set the field's Format to Short Time or enter hh:nn:ss in the Format property. -- Ken Snell MS ACCESS MVP "Wylie C" wrote in message ... I have a time field that I want to store hh:mm:ss. I can set the custom format to 99:00:00 and the user can input the time but no matter what I do the table only displays hh:mm. Thank you. |
#8
|
|||
|
|||
You can't. It is stored as seconds. To format it, you will have to do some
math. Here is an example of storing minutes as hours and minutes. In other words, 120 would display 2:00. You will have to modify it and place it in an unbound field on your form or report... =[SomeFieldName]\60 & Format([SomeFieldName] Mod 60, "\:00") Hope that helps. Rick B "Wylie C" wrote in message ... Rick, I know I should be getting this but I am not. I have changed the field in the table to Number, single. Input mask 99:99:00 and the same on the form. When I run the code, the time stored in the table has no formatting to separate the hrs, min, sec. If I enter 01:00:00 the number the code reads is 10000. How can I store the value in the table as hh:nn:ss? "Rick B" wrote: If I am reading your question correctly... You said you want to store a TIME, not a DURATION. They are two different things. TIME is a specific point in time (1 o'clock, January 15). TIME in this case would never be greater than 24:00:00. DURATION is a length of time spent on a task, or time remaining until an event. This could be any number and can be greater than 24 hours. The key here is that this is a NUMBER, not a TIME. Once you do your calculation, you will get the results in elapses seconds and you can do the division to break it out into hours, minutes, and seconds. 1,000 seconds equals 16 minutes, 40 seconds, for example. Hope that helps, Rick B "Wylie C" wrote in message ... Thanks both but I am still having problems.. When I set the field format to hh:nn:ss and the input mask to 99:99:00 it seems to display and store the time in hours, minutes and seconds. I have set the properties on the form to match the table but the value returned afte data is entered shows am or pm.... What I need to do is the user enters a starting time and an ending time and I need to calculate the average speed. Below is the code I have been working with. I started with only hours and minutes input from the user and am trying to change to the hh:mm:ss. The code works until I get to the seconds part: Private Sub Time_Exit(Cancel As Integer) Dim MyETime, MyEMinute, MyEhour, MyESeconds, ETotlTime MyETime = Me.Time If [OdometerEnd] = "0" Or [OdometerEnd] = "" Then [Route#].SetFocus Else 'Assign a time MyEhour = Hour(MyETime) 'MyEHour contains hours MyEMinute = Minute(MyETime) 'MyEMinute contains minutes MyESeconds = Seconds(MyTime) 'MyESeconds contains seconds ETotlTime = (MyEhour * 60) + (MyEMinute * 60) + MyESeconds Me!ETAveSpeed = ([Mileage] / ETotlTime) * 360 [RideTime].SetFocus End If End Sub I get the error at the MyESeconds = Debugging MyEtime at line 3 shows hh:mm:ss with am/pm "Ken Snell [MVP]" wrote: Oops. Sprinks is correct....it's Long Time, not Short Time. -- Ken Snell MS ACCESS MVP "Ken Snell [MVP]" wrote in message ... In the table's design view, set the field's Format to Short Time or enter hh:nn:ss in the Format property. -- Ken Snell MS ACCESS MVP "Wylie C" wrote in message ... I have a time field that I want to store hh:mm:ss. I can set the custom format to 99:00:00 and the user can input the time but no matter what I do the table only displays hh:mm. Thank you. |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Urgent - Time function question | Carol | Worksheet Functions | 2 | June 4th, 2004 09:31 PM |
Date and time calc formula question | Harlan Grove | Worksheet Functions | 4 | March 30th, 2004 08:09 PM |
Formatting cells to read time in 1/100ths | John Wright | Setting up and Configuration | 1 | March 9th, 2004 10:38 PM |