How to find a date six months ago

Discussion in 'Microsoft Access Form Coding' started by Frederick Wilson, Jan 31, 2005.

  1. Hello all,

    I am trying to write a code for a command but so all the user has to do
    is click it and it will give them the date six months ago from today.

    I can not for the life of me figure this out. DateDiff needs two dates,
    I only know one date which is today's or 'Date()'

    I tried to parse out the parts of the date with month, years and day but
    if you just slap on today's day you could wind up with 31 FEB which we
    all know is not right.

    Hmmm, What to do?

    Thanks,
    Fred
     
    Frederick Wilson, Jan 31, 2005
    #1
    1. Advertisements

  2. Frederick Wilson

    Guest Guest

    NewDate = DateAdd("m", -6, Date())
    This subtracts six months from the current date.

    TomU

    TomU

    "Frederick Wilson" wrote:

    > Hello all,
    >
    > I am trying to write a code for a command but so all the user has to do
    > is click it and it will give them the date six months ago from today.
    >
    > I can not for the life of me figure this out. DateDiff needs two dates,
    > I only know one date which is today's or 'Date()'
    >
    > I tried to parse out the parts of the date with month, years and day but
    > if you just slap on today's day you could wind up with 31 FEB which we
    > all know is not right.
    >
    > Hmmm, What to do?
    >
    > Thanks,
    > Fred
    >
     
    Guest, Jan 31, 2005
    #2
    1. Advertisements

  3. WAY TOO Easy. Thanks

    TomU wrote:
    > NewDate = DateAdd("m", -6, Date())
    > This subtracts six months from the current date.
    >
    > TomU
    >
    > TomU
    >
    > "Frederick Wilson" wrote:
    >
    >
    >>Hello all,
    >>
    >>I am trying to write a code for a command but so all the user has to do
    >>is click it and it will give them the date six months ago from today.
    >>
    >>I can not for the life of me figure this out. DateDiff needs two dates,
    >>I only know one date which is today's or 'Date()'
    >>
    >>I tried to parse out the parts of the date with month, years and day but
    >> if you just slap on today's day you could wind up with 31 FEB which we
    >>all know is not right.
    >>
    >>Hmmm, What to do?
    >>
    >>Thanks,
    >>Fred
    >>
     
    Frederick Wilson, Feb 1, 2005
    #3
  4. Frederick Wilson

    John Vinson Guest

    On Mon, 31 Jan 2005 17:41:36 -0500, Frederick Wilson
    <> wrote:

    >I tried to parse out the parts of the date with month, years and day but
    > if you just slap on today's day you could wind up with 31 FEB which we
    >all know is not right.
    >
    >Hmmm, What to do?


    Two suggestions:

    DateAdd("m", -6, Date())

    DateSerial(Year(Date()), Month(Date()) - 6, Day(Date()))

    These will return March 1 if run on September 30. DateSerial is in
    fact quite clever about handling strange combinations of months and
    days.

    There *are* other date functions... try looking in the Help with the
    VBA editor open to find them!

    John W. Vinson[MVP]
     
    John Vinson, Feb 1, 2005
    #4
  5. Frederick Wilson

    Steph Guest

    Use this:

    =DateAdd(m,6,Date())

    Hope this works,

    Steph

    "Frederick Wilson" <> wrote in message
    news:...
    > Hello all,
    >
    > I am trying to write a code for a command but so all the user has to do
    > is click it and it will give them the date six months ago from today.
    >
    > I can not for the life of me figure this out. DateDiff needs two dates,
    > I only know one date which is today's or 'Date()'
    >
    > I tried to parse out the parts of the date with month, years and day but
    > if you just slap on today's day you could wind up with 31 FEB which we
    > all know is not right.
    >
    > Hmmm, What to do?
    >
    > Thanks,
    > Fred
     
    Steph, Feb 1, 2005
    #5
  6. Frederick Wilson

    Steph Guest

    Sorry I meant to type DateAdd(m,-6,Date())

    Steph

    "Steph" <> wrote in message
    news:%23B2w%...
    > Use this:
    >
    > =DateAdd(m,6,Date())
    >
    > Hope this works,
    >
    > Steph
    >
    > "Frederick Wilson" <> wrote in message
    > news:...
    > > Hello all,
    > >
    > > I am trying to write a code for a command but so all the user has to do
    > > is click it and it will give them the date six months ago from today.
    > >
    > > I can not for the life of me figure this out. DateDiff needs two dates,
    > > I only know one date which is today's or 'Date()'
    > >
    > > I tried to parse out the parts of the date with month, years and day but
    > > if you just slap on today's day you could wind up with 31 FEB which we
    > > all know is not right.
    > >
    > > Hmmm, What to do?
    > >
    > > Thanks,
    > > Fred

    >
    >
     
    Steph, Feb 1, 2005
    #6
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest

    Synchronizing the Main form and six (6) subforms?

    Guest, Dec 27, 2005, in forum: Microsoft Access Form Coding
    Replies:
    11
    Views:
    383
    Rob Oldfield
    Dec 30, 2005
  2. Mike Saifie
    Replies:
    1
    Views:
    1,077
    Jeff Boyce
    Mar 9, 2006
  3. Guest

    CTRL-F (Find) quit working after 6-months of working properly

    Guest, May 31, 2006, in forum: Microsoft Access Form Coding
    Replies:
    0
    Views:
    316
    Guest
    May 31, 2006
  4. iccsi

    find day six month before

    iccsi, Oct 3, 2008, in forum: Microsoft Access Form Coding
    Replies:
    5
    Views:
    327
    Douglas J. Steele
    Oct 5, 2008
  5. Bill Cunningham

    21 years ago today

    Bill Cunningham, Aug 19, 2009, in forum: Microsoft Access Form Coding
    Replies:
    4
    Views:
    5,337
    Bill Cunningham
    Aug 19, 2009
Loading...

Share This Page