+ Reply to Thread
Results 1 to 12 of 12

Dealing with pre 1900 dates

  1. #1
    Registered User
    Join Date
    01-31-2018
    Location
    Australia
    MS-Off Ver
    MS Office pro plus 2016
    Posts
    15

    Dealing with pre 1900 dates

    Hi Folks, Hope you are all well?

    Even chatgpt with all it's wisdom has left me high and dry! Perhaps I am not asking the right questions.

    anyhow I am working with long term historical market data that goes prior to 1900, infact some starts pre 1800.

    I am trying to write formulas that allow me to pick two dates and tell me the time difference between them ( so if data is monthly, it would be number of month od if weekly of daily or less do the same).
    It clearly works on 1900 onwards. I even tried the "Use 1904 date system" option and still can't get it done.

    Below is an example of market data and of course the example is in CSV

    Date,Open,High,Low,Close,Volume
    1789-05-31,0.51,0.51,0.51,0.51
    1789-06-30,0.51,0.51,0.51,0.51
    1789-07-31,0.5,0.5,0.5,0.5
    1789-08-31,0.5,0.51,0.5,0.51
    1789-09-30,0.51,0.51,0.5,0.51
    1789-10-31,0.51,0.51,0.51,0.51
    1789-11-30,0.51,0.51,0.5,0.5
    1789-12-31,0.5,0.5,0.5,0.5

    I see if I can attach an excel file too which also shows my attempts based on chatGPT's suggestion!

    Thanks in Advance
    Regards
    Mini
    Attached Files Attached Files

  2. #2
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Dealing with pre 1900 dates

    If you have selected the "Use 1904 date system" option, you will need to subtract 1,462 days from the start_date and end_date in the formulas to account for the 1904-based date system.

  3. #3
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,706

    Re: Dealing with pre 1900 dates

    in reality, you will need to adjust the strings such that they use compliant dates, and as long as your dates don't predate 1752 I think you should be ok

    =DATEDIF(IFERROR(EDATE(A2,12000),REPLACE(A2,1,1,LEFT(A2)+1)),IFERROR(EDATE(A3,12000),REPLACE(A3,1,1,LEFT(A3)+1)),"d")

    the above basically adds 1000 years to both dates, plagiarised from the great Barry Houdini / Daddylonglegs:

    https://www.mrexcel.com/excel-tips/d...o%20the%20date.

    broadly speaking, dates are integers (time being decimal); integer 1 on Windows equates to 1-Jan-1900 whereas on a Mac it represents 1-Jan-1904; the 1904 option is predominantly used (in Windows context) to facilitate negative datetime values being displayed in datetime format (as long as they do not exceed the 4 year delta) however, this option should be used with extreme caution on pre-existing data (as serials will change etc)

  4. #4
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Dealing with pre 1900 dates

    In the 1904 system and 1900-system, this formula always calculates the correct difference in days from 15-10-1582 according to the Gregorian calendar.
    This formula also sidesteps the problem that Excel mistakenly assumes that 1900 is a leap year.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    @XLent a correction of 1000 years is not correct, because the minimal period all the differences are the same is 400 years. The leap rule is as follows: "If a year is divisible by 4 then it is a leap year, except for the years divisible by 100, then it is not a leap year, except for the years divisible by 400 then it is a leap year."
    So you should add 400 years (4800 months) or a plural of 400 years (eg. 24000 months).
    Last edited by HansDouwe; 06-08-2023 at 02:20 AM.

  5. #5
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Cool Re: Dealing with pre 1900 dates

    is that what you want?
    (without chatGPT )

    Date Open High Low Close Subtraction
    31/05/1789
    0.51
    0.51
    0.51
    0.51
    30
    30/06/1789
    0.51
    0.51
    0.51
    0.51
    30
    31/07/1789
    0.5
    0.5
    0.5
    0.5
    31
    31/08/1789
    0.5
    0.51
    0.5
    0.51
    31
    30/09/1789
    0.51
    0.51
    0.5
    0.51
    31
    31/10/1789
    0.51
    0.51
    0.51
    0.51
    31
    30/11/1789
    0.51
    0.51
    0.5
    0.5
    31
    31/12/1789
    0.5
    0.5
    0.5
    0.5
    31
    31/01/1790
    0.5
    0.5
    0.49
    0.49
    28
    28/02/1790
    0.49
    0.49
    0.49
    0.49
    28
    Attached Files Attached Files
    Last edited by sandy666; 06-08-2023 at 02:49 AM.

  6. #6
    Forum Expert
    Join Date
    12-09-2014
    Location
    Trakai, Lithuania
    MS-Off Ver
    2016
    Posts
    1,429

    Re: Dealing with pre 1900 dates

    Power Query
    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,542

    Re: Dealing with pre 1900 dates

    If all the dates are last day of the month, then simply, G2=--RIGHT(TEXT(A3,"yyyy-mm-dd"),2)

  8. #8
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,515

    Re: Dealing with pre 1900 dates

    Are you required to use Excel for this? Other spreadsheets (LO Calc, Google Sheets) have supported dates prior to 1900 (all the way back to 1 CE Gregorian) for some time. I can open your file in LO Calc, and the formula in column G works just fine without any edits. I sometimes feel like the easiest way to work with pre-1900 dates is to use a different spreadsheet.

    The only thing I would note is that your sample file includes dates back to the 18th century -- when some nations were switching over from Julian to Gregorian. As far as I know, the current systems all extrapolate Gregorian dates back in time. If you ever need to consider the switch from Julian to Gregorian, you will probably need to adjust the date serial numbers to account for it.

    Not sure that helps. It would appear that, if you are restricted to Excel and only Excel, you might be better off switching to Power Query rather than Excel. However you do it, the overall consensus seems to be to abandon Excel because Excel cannot handle pre-1900 dates.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  9. #9
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Dealing with pre 1900 dates

    Quote Originally Posted by MrShorty View Post
    the overall consensus seems to be to abandon Excel because Excel cannot handle pre-1900 dates.
    There is no need to abandon Excel, because its possible to create a working Workaround in Excel. See post #4.

  10. #10
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,515

    Re: Dealing with pre 1900 dates

    There is no need to abandon Excel, because its possible to create a working Workaround in Excel.
    You are, of course, correct and I stand corrected. It still seems like a problem to me if we still need to twist ourselves into knots in Excel to create a workaround for something that other spreadsheets have long made a simple solution for.

  11. #11
    Forum Expert
    Join Date
    12-09-2014
    Location
    Trakai, Lithuania
    MS-Off Ver
    2016
    Posts
    1,429

    Re: Dealing with pre 1900 dates

    Correction
    Please Login or Register  to view this content.
    Last edited by Czeslaw; 06-09-2023 at 03:19 AM.

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,796

    Re: Dealing with pre 1900 dates

    The CSV file has stripped out the query - can you attach the XLSX file?

    EDIT: Thanks!
    Last edited by AliGW; 06-09-2023 at 03:35 AM.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

+ 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. Dealing with dates in VBA
    By j_Southern in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-29-2012, 07:19 AM
  2. Excel 2007 : Dates before 1900
    By TonyRolfe in forum Excel General
    Replies: 3
    Last Post: 06-05-2011, 04:16 AM
  3. Dealing with dates
    By brendanm in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-10-2010, 07:19 PM
  4. dates before 1900
    By jmhultin in forum Excel General
    Replies: 2
    Last Post: 09-03-2009, 11:09 AM
  5. Pre 1900 dates
    By ThaiTrader in forum Excel General
    Replies: 3
    Last Post: 10-20-2008, 05:50 PM
  6. Dates pre 1900
    By tsmorynski in forum Excel General
    Replies: 1
    Last Post: 05-31-2007, 05:57 PM
  7. Pre-1900 dates
    By Richard Gadsden in forum Excel General
    Replies: 1
    Last Post: 03-25-2006, 08:50 PM
  8. Dates before 1900
    By David Cleave in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-18-2005, 09:06 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