Results 1 to 7 of 7
  1. #1
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    date formatting (A2K)

    So, today is June 17th, 2008

    If I display

    =DateAdd("m",-1,Date())

    I get May, which is a good thing

    If I display

    =DateAdd("y",-1,Date())

    I get June, which is not a good thing.

    I was hoping to get 2007

    I've looked through Access Help and the Forum and it would appear that I'm the only one wanting to go back in time.

    Where'd I go wrong?

    Thanks in advance for any help on this

    If I
    Cheers,
    Andy

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: date formatting (A2K)

    Look up DateAdd in the Access VBA help. To add or subtract years, use "yyyy". A single "y" stands for day-of-the-year. So you have to use
    <code>
    =DateAdd("yyyy",-1,Date())</code>

  3. #3
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: date formatting (A2K)

    Hans,

    As I mentioned, I did go both thru the Forum and in VBA Access Help and I had already coded the example you show in your response.

    I also cut and pasted your exact code and still get June as the answer.
    Cheers,
    Andy

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: date formatting (A2K)

    Today it's June 17, 2008. The result of DateAdd("yyyy",-1,Date()) is June 17, 2007. If that is not what you want, please explain what you do want.

  5. #5
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: date formatting (A2K)

    Curiouser and Curiouser.

    As I mentioned in my original question, I was hoping to see the year 2007.

    But, in the meantime, I went searching through my forms and found the exact same code as we've both described.

    So, I cut and pasted the field from the form directly into the report and it displays 2007
    Directly below it is the field that I was playing with which contains the identical code that we both concluded was correct, and it displays June.

    So, I'll delete the bad original and keep the copy. The fact that they have identical code is neither here nor there but is being sent to try me.
    Cheers,
    Andy

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: date formatting (A2K)

    Perhaps they have (or had) different Format properties?

  7. #7
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: date formatting (A2K)

    Stupid computer should have known I meant the format to be yyyy and not mmmm

    <img src=/S/blush.gif border=0 alt=blush width=15 height=15> <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15>
    Cheers,
    Andy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •