How can I enter and display date in Military format?

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.

Advertisements

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.

"JIMW" <> wrote in message
news:...
> 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.

Advertisements

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.

"JIMW" wrote:
> 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.

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

"JIMW" <> wrote in message
news:...
> 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.

Share This Page

Welcome to PC Review!

Hello and welcome to PC Review. We're a friendly computing community, bustling with knowledgeable members to help solve your tech questions.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask any tech support questions, or chat with the community and help others.
Sign up now!