MS Access Date Field / Time Difference

Here is what im using to populate the [time]  field with the time differenceon my form

[Forms]![RCAFRM]![time] = [Forms]![RCAFRM]![SERVAVA] - [Forms]![RCAFRM]![SERVUNA]

My problem is I want to store the time difference in hours / minutes but when I save the record it saves in in time format.

Example = 0:41 will savs as 12:41:00 AM

The format on the time feild is Short Time
mpden32Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Chuck WoodConnect With a Mentor Commented:
The line in the snippet should convert the 0:41 to a string. The field where you save this value (typr?) should have its DataType changed to Text.
[Forms]![RCAFRM]![time] = CStr([Forms]![RCAFRM]![SERVAVA] - [Forms]![RCAFRM]![SERVUNA])

Open in new window

0
 
oleggoldCommented:
You need a variable to calculate Your time first ,possible in int conversion,then populate like,try this
dim dif as variant
dif =  [Forms]![RCAFRM]![SERVAVA] - [Forms]![RCAFRM]![SERVUNA]
[Forms]![RCAFRM]![time] =dif
0
 
Chuck WoodCommented:
A time field will only save time (7:30 AM). You need to use a Text field and format the hours:minutes text string to put in it.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
mpden32Author Commented:
Could you please help me with and example of how to configure my textbox on the from as well as the configureation of the field typr on my table
0
 
MikeTooleConnect With a Mentor Commented:
Datetime values are stored as floating point numbers in Access, e.g. 6pm today is 39939.75
- the .75 represents the time as three quarters of a day, and 39939 is the number of days since 31 Dec 1899
Any formatting you see will be as a result of formatting applied in the user interface.
Presumably the time difference in question really is 41 mins. This would be stored as 0.0284722222222222         i.e.      41/(24*60)
If you format the textbox as Medium Time this will display as 12:41 AM      -    i.e 41 minutes after midnight
Change the format to Short Time and it will display as 00:41 - just as you want.
This will handle time differences upto 23:59  

0
 
mpden32Author Commented:
Ok my goal is to get total time for events if I convert and save the time in my table \ field=totaltime how can I add those together and display back in hous and minutes
0
All Courses

From novice to tech pro — start learning today.