I'm writing a macro where I want to perform several date functions. Essentially I use a GetString to pick up a date from the host, e.g., "01/15/04"
1. I'd like to determine if the mm/dd part of the date is prior to "12/31" and if so, change it to the last day of the month for said "mm" and add one full year to it as well, e.g., "01/15/04" becomes "01/31/05"
2. If, a choice is made to use calendar year vs actual "mm/dd," I'd like it to become the calendar year without adding another year, e.g., 01/15/04 becomes 12/31/04
4. Then once the initial date scheme is settled (1-2 above) I need to increase the date by one year for each iteration I'm running. From that date I want to be able to add 1 year to it. Not just 365 days as it gets confusing in case of leap year.
I do have many snippets of code I've tried to accomplish this with but fear major embarassment if I supply it. I will add one trial piece for perusal:
tmp = objWorkBook.Worksheets("ListInfo").cells( xlRow, 5 ) 'formatted as mentioned above
IncDt = Format( tmp, "mm/dd/yy") 'attempt to format
tmp = "" 'clear to reuse variable
tmp = objWorkBook.Worksheets("ListInfo").cells( xlRow, 4 ) 'captures mm/dd only
minDate = Format( tmp, "mm/dd") 'just to pull those values out to run function to either use calendar year ending or last day of listed month
tmp = ""
yrShort = Format (IncDt , "yy") 'to get yy only for a function (can't actually remember what)
yrLong = Format (IncDt , "yyyy") 'this to get a full ccyy as when comparing years from 1900's to 2000's must have full ccyy.
Thank you for your assistance.
Jeane
1. I'd like to determine if the mm/dd part of the date is prior to "12/31" and if so, change it to the last day of the month for said "mm" and add one full year to it as well, e.g., "01/15/04" becomes "01/31/05"
2. If, a choice is made to use calendar year vs actual "mm/dd," I'd like it to become the calendar year without adding another year, e.g., 01/15/04 becomes 12/31/04
4. Then once the initial date scheme is settled (1-2 above) I need to increase the date by one year for each iteration I'm running. From that date I want to be able to add 1 year to it. Not just 365 days as it gets confusing in case of leap year.
I do have many snippets of code I've tried to accomplish this with but fear major embarassment if I supply it. I will add one trial piece for perusal:
tmp = objWorkBook.Worksheets("ListInfo").cells( xlRow, 5 ) 'formatted as mentioned above
IncDt = Format( tmp, "mm/dd/yy") 'attempt to format
tmp = "" 'clear to reuse variable
tmp = objWorkBook.Worksheets("ListInfo").cells( xlRow, 4 ) 'captures mm/dd only
minDate = Format( tmp, "mm/dd") 'just to pull those values out to run function to either use calendar year ending or last day of listed month
tmp = ""
yrShort = Format (IncDt , "yy") 'to get yy only for a function (can't actually remember what)
yrLong = Format (IncDt , "yyyy") 'this to get a full ccyy as when comparing years from 1900's to 2000's must have full ccyy.
Thank you for your assistance.
Jeane