Results 1 to 6 of 6
  1. #1
    arneym is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Location
    Indiana
    Posts
    17

    How to format the =Now() to a specific format in VB

    Hello All,



    I am creating a button to generate a date/time stamp as the form number. I need it to generate YYMMDD-HHMM
    I am not having any luck. Please HELP!!

  2. #2
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    I found this helpful link...

    http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx

    Looks like


    ("yy mm, dd")
    "MM" The month, from 01 through 12.
    More information: The "MM" Custom Format Specifier.
    6/15/2009 1:45:30 PM -> 06
    "yy" The year, from 00 to 99.
    More information: The "yy" Custom Format Specifier.
    1/1/0001 12:00:00 AM -> 01
    1/1/0900 12:00:00 AM -> 00
    1/1/1900 12:00:00 AM -> 00
    6/15/2009 1:45:30 PM -> 09
    "dd" The day of the month, from 01 through 31.
    More information: The "dd" Custom Format Specifier.
    6/1/2009 1:45:30 PM -> 01
    6/15/2009 1:45:30 PM -> 15

  3. #3
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Try:

    Format(Now(), "yymmdd-hhmm")

  4. #4
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    Sorry

    =Now("yy mm, dd - HH MM ")


    "HH" The hour, using a 24-hour clock from 00 to 23.
    More information: The "HH" Custom Format Specifier.
    6/15/2009 1:45:30 AM -> 01
    6/15/2009 1:45:30 PM -> 13

    "MM" The month, from 01 through 12.
    More information: The "MM" Custom Format Specifier.
    6/15/2009 1:45:30 PM -> 06

  5. #5
    arneym is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Location
    Indiana
    Posts
    17
    Quote Originally Posted by JoeM View Post
    Try:

    Format(Now(), "yymmdd-hhmm")
    Thank you, JoeM!!
    This produced exactly what I was asking for!!

    Code:
    Private Sub btnDateTime_Click()
    Me.txtDateTime = Format(Now(), "YYMMDD-HHMM")


    End Sub

  6. #6
    arneym is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Location
    Indiana
    Posts
    17
    Thank you, redbull!

    I appreciate your help.

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

Similar Threads

  1. Number Format to General Format
    By mkc80 in forum Access
    Replies: 2
    Last Post: 05-05-2012, 02:10 AM
  2. Exporting a query to a specific Excel format
    By Ronald Mcdonald in forum Import/Export Data
    Replies: 3
    Last Post: 04-27-2012, 10:29 AM
  3. Replies: 3
    Last Post: 03-05-2012, 04:06 PM
  4. Exporting to .txt with Specific Format
    By KrenzyRyan in forum Import/Export Data
    Replies: 12
    Last Post: 11-18-2011, 04:57 AM
  5. format
    By nkuebelbeck in forum Queries
    Replies: 1
    Last Post: 03-23-2010, 10:22 AM

Tags for this Thread

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