+ Reply to Thread
Results 1 to 3 of 3

DateAdd from December to January not updating year

  1. #1
    Registered User
    Join Date
    04-21-2016
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    2016
    Posts
    26

    DateAdd from December to January not updating year

    I am using DateAdd to determine the dates for worker's review periods from a start date.

    This has worked fine all year, but now I have a group that span December to January and the date in January has the correct day, but the year is still 2016.

    There are 5 consecutive review periods, this is the code for the first two months, the rest just iterates.
    The code looks like this:
    Please Login or Register  to view this content.
    Is there a way to have DateAdd recognize that the year has rolled over?

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: DateAdd from December to January not updating year

    I would guess the problem is that StartPeriod is a string, and perhaps the year is entered as "16" instead of "2016"? working with strings as dates can be messy, and you may be better of converting the string to an actual date variable before using the DateAdd function.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    04-21-2016
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    2016
    Posts
    26

    Re: DateAdd from December to January not updating year

    Quote Originally Posted by Arkadi View Post
    I would guess the problem is that StartPeriod is a string, and perhaps the year is entered as "16" instead of "2016"? working with strings as dates can be messy, and you may be better of converting the string to an actual date variable before using the DateAdd function.
    Thanks, it turns out I was looking in the wrong place for the source of my problems - the dateadd was working ok, it was the string output variable's formatting that was causing issues. But I wouldn't have gone down that track without your tip to look at strings vs date.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. January of current year
    By sdjames1979 in forum Excel General
    Replies: 1
    Last Post: 09-03-2015, 07:01 AM
  2. [SOLVED] Change From 1 January 2015 Thursday to 1 January 2015 Thu
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-14-2015, 11:47 AM
  3. Replies: 2
    Last Post: 02-20-2015, 07:44 AM
  4. Year to Date Updating
    By Dimmins in forum Excel General
    Replies: 7
    Last Post: 07-02-2013, 09:28 AM
  5. Updating dates for new year
    By boneob in forum Excel General
    Replies: 5
    Last Post: 01-21-2013, 12:49 AM
  6. Replies: 3
    Last Post: 05-16-2012, 03:55 PM
  7. Updating excel sheets by year
    By jimmisavage in forum Excel General
    Replies: 1
    Last Post: 06-25-2007, 11:15 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1