Results 1 to 4 of 4
  1. #1
    tagteam is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    501

    Getting just month out of a date

    I am trying to use



    Month: Trim(Mid([Date & Time],InStr(1,[Date & Time],"/")+1,InStr(InStr(1,[Date & Time],"/")+1,[Date & Time],"/")-InStr(1,[Date & Time],"/")))

    But i end up with an extra /

    For example: 1/11/2019 ends up giving me 11/

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,741
    MyMonth: month([Date & Time])

  3. #3
    tagteam is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    501
    oops, my bad, I meant day. I get the month fine but i need the day. So I ran with your oh so easy idea and get Day: Day([Date & Time])

    I would say that is somewhat easier than my first idea.

    Thank you

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    you need to be clear about what you have. Date and Time are both reserved names meaning today and the time now (Now is a combination of both)

    So if you are using Date and Time as the Date and Time functions, i.e. Now then you should be aware that date/time fields are numeric, not a string. What you see as 01/15/2018 is just a format of the number. As a number you do not use string functions such as Trim and &. you would add them together - Date+Time (or Now if you prefer)

    Alternatively if your Date and Time are strings then VBA is probably confused about whether to use your field or the function.

    And if you are only trying to find the month, you do not need the time element

    Edit: Day is also a reserved word - as you can see because it is a function

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

Similar Threads

  1. Replies: 1
    Last Post: 11-27-2017, 02:02 PM
  2. Replies: 4
    Last Post: 05-03-2017, 09:48 AM
  3. Replies: 43
    Last Post: 08-06-2014, 08:21 PM
  4. Replies: 4
    Last Post: 05-26-2013, 03:28 PM
  5. Replies: 3
    Last Post: 04-01-2012, 01:40 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