+ Reply to Thread
Results 1 to 13 of 13

Date conversion - Excel presents system report date incorrectly

  1. #1
    Registered User
    Join Date
    02-01-2017
    Location
    Stockholm
    MS-Off Ver
    2010
    Posts
    5

    Date conversion - Excel presents system report date incorrectly

    Hi all,

    I have a problem with dates in my Excel-report and I'm hoping you can help me.

    The system I draw reports from presents the system dates like this in the application itself: 24/01/17 - which is fine, however, when I print a report or copy the data to Excel, Excel somehow views the data as missing 2-digits.
    This causes = 24/01/17 to become 2024-01-17. Also there are dates like 31/05/13 that becomes 1931-05-13.

    I'm told that this is due to some settings on my laptop, however I do not want to change any settings at all on the hardware as the problem above only exists in 1 report out of almost 60.
    How can I resolve the problem in Excel, with a formula?

    Thanks in advance!

    //Fred

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Date conversion - Excel presents system report date incorrectly

    Your system is holding the data in one way (YYYY MM DD) and displaying it another way (DD MM YY)

    How are you copying the information from your system and how are you pasting into Excel?
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Forum Expert avk's Avatar
    Join Date
    07-12-2007
    Location
    India
    MS-Off Ver
    Microsoft Office 2013
    Posts
    3,223

    Re: Date conversion - Excel presents system report date incorrectly

    Problem for system date format. You can do as per below.
    > Go to Start
    > Click on "Control Panel"
    > Open "Regional and language options"
    > In Regional options : Clcik on "Customize" > Click on "Date" tab & change as in "short date format" : dd/MMM/yyyy
    and "long date format" : dddd, MMMM dd, yyyy
    Clcik on "apply" & "ok"


    atul


    If my answer (or that of other members) has helped you, please say "Thanks" by clicking the Add Reputation button at the foot of one of their posts.

    Also: if your problem is solved, please take the time to mark your thread as SOLVED by going to the top of your first post, selecting "Thread Tools" and then "Mark thread as solved".

  4. #4
    Registered User
    Join Date
    02-01-2017
    Location
    Stockholm
    MS-Off Ver
    2010
    Posts
    5

    Re: Date conversion - Excel presents system report date incorrectly

    Ah OK. Well, the system produces a report in .CSV format. Normally we just save the report as an .xlsx locally and go to work with the data, so no copying as such is done, I kind of "get what I get" from the system. There is no view in which I could copy the data straight from they delivering system unfortunately.

    AVK, Yes, I was told to do so by others as well, however, this is exactly what I don't want to, as my other 58 reports which have for me the correct format on date, will then have the above described issue. To add to this, we generally can't change these settings on our laptops either - company policy. Thanks for replying though
    Last edited by Fred Johs; 02-01-2017 at 07:48 AM.

  5. #5
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Date conversion - Excel presents system report date incorrectly

    Please attach the .csv file - I would like to see the original format before it comes into Excel and before anybody does anything to it. Perhaps you can run a short report without any confidential data - make sure the "dates" are ones that cause you the problem.

    If that is not possible then attach the .xlsx file with "XXX" instead of text

    thanks
    Last edited by kev_; 02-01-2017 at 09:57 AM.

  6. #6
    Registered User
    Join Date
    02-01-2017
    Location
    Stockholm
    MS-Off Ver
    2010
    Posts
    5

    Re: Date conversion - Excel presents system report date incorrectly

    I have attached a .csv file (report) as mentioned.
    Last edited by Fred Johs; 02-02-2017 at 06:07 AM.

  7. #7
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Date conversion - Excel presents system report date incorrectly

    If you open the .csv file with Notepad these are the values

    Company,SHP Date,LD Date
    XYZ,2003-02-16,2005-05-16
    XYZ,2003-02-16,2004-05-16
    XYZ,2022-01-16,2025-04-16
    XYZ,2022-02-16,2023-03-16
    XYZ,2022-02-16,2002-06-16

    So the problem is in how the data was exported to the .csv file

    There are 3 choices:
    1) BEST SOLUTION: fix the problem when data exported from system to .csv
    2) ALTERNATIVE1 write VBA routine to convert the data
    3) ALTERNATIVE2 use a formula to convert the data

    Note
    When the data is in Excel, Excel is changing the text into a number. All dates are held as numbers.
    Excel sees 16/02/2003 as 37668
    Excel sees 03/02/2016 as 42403


    Are you able to ask somebody to fix the .csv file?
    This problem is happening when the .csv file is being created.
    I think someone has made an error that could be fixed

  8. #8
    Registered User
    Join Date
    02-01-2017
    Location
    Stockholm
    MS-Off Ver
    2010
    Posts
    5

    Re: Date conversion - Excel presents system report date incorrectly

    I see. I had a suspicion that the system as such was at fault as other reports are coming out fine. The thing is, making changes to this application is an issue, it will most likely take a very long time if they choose to make any corrections. So, I would really appreciate the alternate solutions to this issue. That would help a great deal.

  9. #9
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Date conversion - Excel presents system report date incorrectly

    This solution assumes that all the "BAD" dates are between 01/01/2000 and 31/12/2999

    Dates in Excel are simply numbers formatted a special way.
    The "number" held by Excel is incorrect and so when formatted as a date is giving the incorrect date.
    So we need to find a way to re-calculate the number.

    Here is one way to convert:

    "BAD" date is in B2
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    For consistency I have treated "month" like "year" & "day" - but of course the month is correct in either format!

    The formula
    - formats what Excel treats as the "year" as 2 digit text (= DAY)
    - formats the "month" as 2 digit text (= MONTH)
    - formats what Excel treats as the "day" as 2 digit text (= YEAR with 2 digits)
    - inserts "20" before those 2 digits (= YEAR with 4 digits)
    - feeds those values into the Date function
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  10. #10
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Date conversion - Excel presents system report date incorrectly

    Excel also seems happy with
    Please Login or Register  to view this content.

    Late EDIT
    And you can format in any date format you want, because the result is a number
    Last edited by kev_; 02-01-2017 at 05:57 PM.

  11. #11
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Date conversion - Excel presents system report date incorrectly

    If this is a regular problem you will need to keep putting adding the formula every time you receive a .csv (tedious??)

    If you want a VBA solution to run against the .csv file I will need some more information
    - which Columns need converting
    - which row does the data start (not the Headings)
    - are there any values other than dates in those columns?

  12. #12
    Registered User
    Join Date
    02-01-2017
    Location
    Stockholm
    MS-Off Ver
    2010
    Posts
    5

    Re: Date conversion - Excel presents system report date incorrectly

    Thanks Kev_ your solution works great. I've managed to get the formula into a macro as well, so now the reports are being converted easy.

    Thanks again for the quick response and support!

    //F

  13. #13
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Date conversion - Excel presents system report date incorrectly

    It was very kind of you not to point out my exaggerated claim
    This solution assumes that all the "BAD" dates are between 01/01/2000 and 31/12/2999
    - I am sure you noticed that the solution is only good until 2099.
    Glad your problem is resolved and that you have converted the formula to VBA.
    Thanks for the reps

    Below is VBA solution where values in Columns B,C,G & H are errant dates - starting in row2
    The VBA overwrites the original values with the correct values.
    The macro (as written) needs to be run from the sheet containing the values.

    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)

Similar Threads

  1. Excel VBA - Closing calendar in userform incorrectly inserts date in the textbox
    By pi_tiger in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-01-2015, 06:40 PM
  2. [SOLVED] (Automation Error) How to retrive data between from date to system date using excel VBA
    By Kalpesh93 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-22-2015, 06:50 AM
  3. [SOLVED] VBA Macro to Color Row Text If Date in Cell is greater than system date
    By slick9456 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-24-2014, 06:09 PM
  4. Replies: 7
    Last Post: 10-01-2013, 05:06 PM
  5. Replies: 0
    Last Post: 01-16-2013, 12:14 AM
  6. Date independent of System date in column of Excel
    By gaursh in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-25-2011, 06:30 AM
  7. date in Excel displays incorrectly when merged in letter
    By Feather 52 in forum Excel General
    Replies: 1
    Last Post: 03-13-2006, 06:40 PM

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