How can I enter and display date in Military format?

Discussion in 'Microsoft Access' started by Guest, Dec 21, 2005.

  1. Guest

    Guest 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.
     
    Guest, Dec 21, 2005
    #1
    1. Advertisements

  2. Guest

    Allen Browne Guest

    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.

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "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.
     
    Allen Browne, Dec 21, 2005
    #2
    1. Advertisements

  3. Guest

    Guest 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.


    "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.
     
    Guest, Dec 21, 2005
    #3
  4. Guest

    Dave Emmert Guest

    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.
     
    Dave Emmert, Dec 23, 2005
    #4
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Douglas J. Steele

    Re: Military Date Format

    Douglas J. Steele, Apr 21, 2004, in forum: Microsoft Access
    Replies:
    0
    Views:
    650
    Douglas J. Steele
    Apr 21, 2004
  2. David Mann

    Re: Military Date Format

    David Mann, Apr 21, 2004, in forum: Microsoft Access
    Replies:
    0
    Views:
    316
    David Mann
    Apr 21, 2004
  3. Tony Toews

    Re: Military Date Format

    Tony Toews, Apr 22, 2004, in forum: Microsoft Access
    Replies:
    2
    Views:
    647
    Rebecca Riordan
    Apr 23, 2004
  4. Guest
    Replies:
    0
    Views:
    241
    Guest
    Dec 21, 2005
  5. Guest
    Replies:
    4
    Views:
    1,040
    Wayne Morgan
    Mar 24, 2006
Loading...

Share This Page