PC Review


Reply
Thread Tools Rate Thread

How to find a date six months ago

 
 
Frederick Wilson
Guest
Posts: n/a
 
      31st Jan 2005
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tVQ==?=
Guest
Posts: n/a
 
      31st Jan 2005
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
>

 
Reply With Quote
 
 
 
 
Frederick Wilson
Guest
Posts: n/a
 
      1st Feb 2005
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
>>

 
Reply With Quote
 
John Vinson
Guest
Posts: n/a
 
      1st Feb 2005
On Mon, 31 Jan 2005 17:41:36 -0500, Frederick Wilson
<(E-Mail Removed)> 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]
 
Reply With Quote
 
Steph
Guest
Posts: n/a
 
      1st Feb 2005
Use this:

=DateAdd(m,6,Date())

Hope this works,

Steph

"Frederick Wilson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
Steph
Guest
Posts: n/a
 
      1st Feb 2005
Sorry I meant to type DateAdd(m,-6,Date())

Steph

"Steph" <(E-Mail Removed)> wrote in message
news:%23B2w%(E-Mail Removed)...
> Use this:
>
> =DateAdd(m,6,Date())
>
> Hope this works,
>
> Steph
>
> "Frederick Wilson" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"the date two months ago (from today)" ? =?Utf-8?B?VHJ1bmtz?= Microsoft Access 4 30th Nov 2005 02:33 AM
How do I find archived emails from the past six months? =?Utf-8?B?VG9tIC0gQ09P?= Microsoft Outlook Form Programming 0 24th Mar 2005 06:59 PM
Query Date from current months first day to one year ago =?Utf-8?B?TWljaGFlbA==?= Microsoft Access Queries 1 2nd Feb 2005 12:59 AM
HOW TO TURN SIX DOLLARS INTO SIX THOUSAND DOLLARS: READING THISCOULD CHANGE YOUR LIFE! IT DOES WORK! Brian Windows XP General 0 12th Jan 2005 03:36 AM
XL 2000 six digit number and separate it into six separate cells Alan Microsoft Excel Misc 8 27th Mar 2004 10:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:39 AM.