Results 1 to 4 of 4
  1. #1
    WithoutPause is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    62

    Formatting military time into non-military time

    I'm trying to format time in short form without using military time as the AM/PM data is being stored in a separate field. The following code doesn't work. I get a run-time error of 13 and type mismatch. DateAdd won't work since the format of the returned data is in Long Time form.

    Private Sub CTime_AfterUpdate()
    If Hour([CTime]) > 12 Then
    CTime = Format((Hour([CTime]) - 12) + ":" + Minute([CTime]), "Short Time")


    End If
    End Sub

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    ummmmm - I'm not sure if there is a disconnect or if I misunderstand your post. Time is time. It can be 'displayed' either military or traditional. No coding is needed. When in design view of the object being seen (typically form or report) option the text box control format to be either Medium Time or Short Time.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    This error is triggered because the + is trying to add. Can't add string ":", therefore datatype mismatch.

    Use & for concatenation.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    WithoutPause is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    62
    Quote Originally Posted by June7 View Post
    This error is triggered because the + is trying to add. Can't add string ":", therefore datatype mismatch.

    Use & for concatenation.
    Thanks. I figured it was something simple.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Military Time Blues
    By viperbyte in forum Forms
    Replies: 19
    Last Post: 04-14-2020, 06:45 AM
  2. Replies: 1
    Last Post: 03-14-2013, 10:16 AM
  3. Replies: 42
    Last Post: 03-01-2013, 06:58 AM
  4. Replies: 14
    Last Post: 01-15-2013, 06:07 PM
  5. Military Time
    By tshirttom in forum Access
    Replies: 3
    Last Post: 07-29-2011, 01:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums