Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Calculating Dates in VBA

I want to write some code that will calculate a date. I
need to calcuate an expiration date. The expiration date
will always be 1 year minus a day from the effective
date. So if the effective date = 6/1/2003, then the
expiration date = 5/31/04. I can do this pretty easily
within an excel worksheet, but I would like this to
happen with code.

Thanks
Mike


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Calculating Dates in VBA

Its actually quite easy in VBA. A function like this for example:

Function ExpirationDate(StartDate As Date) As Date
ExpirationDate = DateAdd("yyyy", 1, StartDate) - 1
End Function

Used like:

?ExpirationDate(DateSerial(2003,6,1))
5/31/2004


--
Regards,

Juan Pablo González

"Squid" wrote in message
...
I want to write some code that will calculate a date. I
need to calcuate an expiration date. The expiration date
will always be 1 year minus a day from the effective
date. So if the effective date = 6/1/2003, then the
expiration date = 5/31/04. I can do this pretty easily
within an excel worksheet, but I would like this to
happen with code.

Thanks
Mike




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Calculating Dates in VBA

Thank you... knew if was simple. .


"Juan Pablo González" wrote in message
...
Its actually quite easy in VBA. A function like this for example:

Function ExpirationDate(StartDate As Date) As Date
ExpirationDate = DateAdd("yyyy", 1, StartDate) - 1
End Function

Used like:

?ExpirationDate(DateSerial(2003,6,1))
5/31/2004


--
Regards,

Juan Pablo González

"Squid" wrote in message
...
I want to write some code that will calculate a date. I
need to calcuate an expiration date. The expiration date
will always be 1 year minus a day from the effective
date. So if the effective date = 6/1/2003, then the
expiration date = 5/31/04. I can do this pretty easily
within an excel worksheet, but I would like this to
happen with code.

Thanks
Mike






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculating pay dates BW Excel Worksheet Functions 4 June 6th 10 04:58 AM
Calculating Dates Gaza[_2_] Excel Worksheet Functions 7 May 12th 09 10:57 AM
Calculating Dates brewster56 Excel Worksheet Functions 4 April 28th 09 06:57 PM
Calculating with dates Henk Excel Discussion (Misc queries) 3 June 13th 07 04:24 PM
Calculating number of days between two dates that fall between two other dates [email protected] Excel Discussion (Misc queries) 5 October 26th 05 06:18 PM


All times are GMT +1. The time now is 01:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"