Results 1 to 3 of 3
  1. #1
    NISMOJim is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    273

    Date as date name

    OK, here's a little thing that's driving me nuts tonight. Since today's date is 10/4/12, how come MyLastMonth isn't coming out to be "September"? Instead, I'm getting a runtime error 13 type mismatch. When I hover my mouse over MyLastMonth it shows MyLastMonth=12:00:00 AM.

    Dim MyDate As Date
    Dim MyLastMonth As Date


    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    MyDate = Date
    MyLastMonth = Format(MyDate, "mmmm")


    MyLastMonth = MyLastMonth - 1

    I've come a long way in my code tonight only to be set back by something as simple as this!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Result of Format function is a text string.

    Format(MyDate,"mmmm") should return January, February, etc. and can't subtract 1 from 'January'

    Try:
    Format(DateAdd("m",-1,Date()),"mmmm")
    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.

  3. #3
    NISMOJim is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    273
    Thank you June7, perfect!

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

Similar Threads

  1. Replies: 3
    Last Post: 08-21-2012, 03:05 PM
  2. Replies: 12
    Last Post: 04-26-2012, 04:01 AM
  3. Replies: 15
    Last Post: 04-06-2012, 10:57 AM
  4. Replies: 3
    Last Post: 04-01-2012, 01:40 PM
  5. Replies: 1
    Last Post: 07-07-2010, 04:22 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