How can I enter and display date in Military format?

G

Guest

I'm doing an application in which we wish to enter and display all dates in
Standard Military format. I am using general date format. Date Time Group
is to be entered and displayed as: ddHHnnZmmmyy For example: 011200ZJan06.
The Z is the ZULU or Greenwich Mean Time Zone.
 
A

Allen Browne

Okay, lets start with how Access stores dates, and work towards the
interface you want.

Internally, Access uses a real number to store a date/time value. The
integer part is the date; the fractional part is the time as a fraction of a
day (0.5 = noon; 0.25 = 6am.)

You can display the date/time value in the way you want by setting the
Format property of the text box on your form or report to:
ddHHnn\Zmmmyy

But you will not be able to enter the date/time value like that. You will
therefore need to use an unbound text box to accept the entry, and then use
the AfterUpdate event of that text box to parse the value and write the date
to the date/time field, using Mid(), Len(), DateSerial() and TimeSerial() to
generate the date time value.

On your form, set the Tab Stop property of the real date/time field (named
DT in the example) to No so it does not receive focus when tabbing through
the form. In case the user clicks on it, set its On Got Focus property to
[Event Procedure], and assign its value to that of the unbound entry box:
Me.txtEntry.SetFocus

Set the tab order of the unbound box so it does take focus when DT would
have. In its Got Focus event, copy the value from DT:
If IsNull(Me.DT) Then
Me.txtEntry = Null
Else
Me.txtEntry = Format(Me.DT, "ddHHnn\Zmmmyy")
End If

Then in the AfterUpdate event procedure of the unbound entry box, parse the
string to create a real date/time value (delimited with #), and assign it to
DT.
 
G

Guest

Allen:Thanks very much, I'm sure this will deliver what we want. I was kind
of hoping we could handle in in table design, but there is that missing step.
You can tell the system you want the general date and you can determine the
input mask but the step in between - telling it what information it will be
receiving from the field input is missing. Thanks again.
 
D

Dave Emmert

You can display date/time in DTG format with the following format:
ddHHnn"Z"mmmyy

However for inputing the date, you will need to input in the general
date/time format: 12/1/2005 12:05:00 PM. You could create a unbounded
textbox that would change the dtg to the long date/time format for the
database, but I think that it would be too much trouble for the effort.

In our offices, we use two different fields, one for dtg as a text field (as
an FYI) and another as a date field (short date format) for queries.

Dave
 

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