+ Reply to Thread
Results 1 to 5 of 5

Date format issue

  1. #1
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,174

    Date format issue

    I am importing a large excel file from with ~2500 line items. I am having issues with excel formating some of the dates to a year 19xx format instead of a 20xx format.

    For example: some of the values that are being copied are 3/15/43 or 9/22/47. Then value is being converted to 03/15/1943 and to 09/22/1947. Is there an easy way to convert these value back to a 20xx format. I tried using the custom button with "mm/dd/20yy" but didn't work. Thanks for any comments.
    Last edited by maacmaac; 04-22-2010 at 08:32 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Date format issue

    See http://support.microsoft.com/kb/214391
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,174

    Re: Date format issue

    Link helped a little but couldn't quite figure how to incorporate. The problem is that the data I am getting from another spreadsheet is already messed up (i.e. there are dates that are formatted as 19xx and they shouldn't be)

    I did come up with a work around that I think might work. I am going through each cell to determine if it is less than 01/01/2000. If it is less than 01/01/2000, then add 100 years to the year.

    The code I tried using is as follows but can't figure out why it won't work. Not sure if the "Date" function is available in VBA
    Please Login or Register  to view this content.
    Thanks for any comments

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Date format issue

    Think you wanna subtract 100 years:
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,174

    Re: Date format issue

    Shg, thanks for the great tip. I actually need to add 100 years. If the current value of a cell is 09/18/1947, I need it to convert to 09/18/2047. I changed code to add 100 and ran it through a number of examples and it appears to be correctly (also had to change the "#1/1/2010#" portion to "#1/1/2000#"). Thanks again for your assistance
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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