Writing a General Date from separate date and time fields

D

DubboPete

Hi all,

I have records which need to be modified, to allow for "after-the-
fact" entries. What I am trying to achieve is combining a date field
(formatted as Medium Date) and a time field (formatted Short Time)
from a form entry, and then updating a field in the table which is
formatted as General Date.

It will normally be to give the correct timestamp for the start of a
phone call, even if the database entry is made two hours later.

The purpose? So I can correctly calculate the difference between two
General Dates, [CallDate] and [CallEnd], (and the associated
timestamps), and calculate hours and minutes.

Any help greatly appreciated, and hope that's enough information.

TIA

DubboPete
 
J

John W. Vinson

Hi all,

I have records which need to be modified, to allow for "after-the-
fact" entries. What I am trying to achieve is combining a date field
(formatted as Medium Date) and a time field (formatted Short Time)
from a form entry, and then updating a field in the table which is
formatted as General Date.

It will normally be to give the correct timestamp for the start of a
phone call, even if the database entry is made two hours later.

The purpose? So I can correctly calculate the difference between two
General Dates, [CallDate] and [CallEnd], (and the associated
timestamps), and calculate hours and minutes.

Any help greatly appreciated, and hope that's enough information.

TIA

DubboPete

An Access Date/Time value is stored as a Double Float number, a count of days
and fractions of a day (times) since midnight, December 30, 1899. The Format
is *absolutely irrelevant* - it doesn't affect what's stored, just what's
displayed. As a rule, it's simplest to put both the date and time into one
Date/Time field rather than two separate fields. You can enter

2/10/2010 11:25:29PM

into a date/time field just as easily as you can enter the components into two
fields, and once you have done so you can use DateDiff to calculate the
elapsed time between the start and end.
 
D

DubboPete

I have records which need to be modified, to allow for "after-the-
fact" entries.   What I am trying to achieve is combining a date field
(formatted as Medium Date) and a time field (formatted Short Time)
from a form entry, and then updating a field in the table which is
formatted as General Date.
It will normally be to give the correct timestamp for the start of a
phone call, even if the database entry is made two hours later.
The purpose?  So I can correctly calculate the difference between two
General Dates, [CallDate] and [CallEnd], (and the associated
timestamps), and calculate hours and minutes.
Any help greatly appreciated, and hope that's enough information.

DubboPete

An Access Date/Time value is stored as a Double Float number, a count of days
and fractions of a day (times) since midnight, December 30, 1899. The Format
is *absolutely irrelevant* - it doesn't affect what's stored, just what's
displayed. As a rule, it's simplest to put both the date and time into one
Date/Time field rather than two separate fields. You can enter

2/10/2010 11:25:29PM

into a date/time field just as easily as you can enter the components into two
fields, and once you have done so you can use DateDiff to calculate the
elapsed time between the start and end.

--

             John W. Vinson [MVP]- Hide quoted text -

- Show quoted text -

Hi John,

I appreciate that, but the user wants to enter just a time... not the
date/time. I suppose in that case then I can merge them both into a
text field and then update the General date field with the combined
contents.

Thanks for that!

Pete
 
J

John W. Vinson

I appreciate that, but the user wants to enter just a time... not the
date/time. I suppose in that case then I can merge them both into a
text field and then update the General date field with the combined
contents.

Another idea would be to automatically "fix it up" to today's date. On the
Form you can use the AfterUpdate event of the textbox:

Private Sub txtTime_AfterUpdate()
' See if user entered only a time; if so it will be sometime on 12/30/1899
If DateValue(Me!txtTime) < #12/31/1899# Then
Me!txtTime = Date() + Me!txtTime
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top