+ Reply to Thread
Results 1 to 5 of 5

Perplexing DATE calculations problem

  1. #1
    Registered User
    Join Date
    03-03-2011
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    53

    Perplexing DATE calculations problem

    Please be patient, I am still relatively new to VBA and have now hit Date problems.

    I have a sheet of burial records, one column contains the death dates, many of which are post 1900 (13/03/1961), but a lot are pre 1900 (28 December 1874). Another column contains the age at death in various formats which in all cases I have been able to convert to a count of DAYS.

    For output to a file for another program I need to calculate the birth date, i.e Death Date - age in days, as the majority of these will become pre 1900 dates this would be preferrable in Text date format e.g 15 February 1886.

    My first thinking was to temporarily increase the century on all dates,
    century = Val(Mid(deathdate, (Len(deathdate)-3),2))+1 subtract the age in days using Excel, decrease the century again by the same amount and construct a Text date.

    My first problem was getting the date calculation to work,

    birth = Val(Cells(r, 3)) - Val(cells(r,4)) does not work
    where column 3 is 17/06/1978 and column 4 is 25915 which should give me 05/07/1907 but doesn't, without the VAL I still have the same problem.

    All help and suggestions on the best way tp proceed gratfully received.

    Thx in advance

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Perplexing DATE calculations problem

    Why do you have the age in days? Wouldn't mm/dd/yy be better so it could be a date subtraction?
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Registered User
    Join Date
    03-03-2011
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    53

    Re: Perplexing DATE calculations problem

    Quote Originally Posted by XeRo Solus View Post
    Why do you have the age in days? Wouldn't mm/dd/yy be better so it could be a date subtraction?
    Ignorance I would think, I thought that as Excel uses a decimal for the date starting 30 Dec 1899 that would be the best base. The original age at death contained various formats like "71", "10 Months", "18 Days", "1 6/12 Years" etc so I thought I would calculate days as a common base, I can easily re-do it.

    Looks like this was not the right approach, so what would you suggest?

    And what do you think of my increasing and decreasing the century idea to help with pre 1900 date results?

    Thx

  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: Perplexing DATE calculations problem

    Quote Originally Posted by Orada View Post
    And what do you think of my increasing and decreasing the century idea to help with pre 1900 date results?
    I think it's a fine idea. Or you could use an add-in: http://j-walk.com/ss/excel/files/xdate.htm
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    03-03-2011
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    53

    Re: Perplexing DATE calculations problem

    Quote Originally Posted by shg View Post
    I think it's a fine idea. Or you could use an add-in: http://j-walk.com/ss/excel/files/xdate.htm
    Thanks, that could be useful to my needs

  6. #6
    Registered User
    Join Date
    03-03-2011
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    53

    Re: Perplexing DATE calculations problem

    Thanks for the suggestions but I have found a solution through using CDate which also works pre 1900 so I can generate the output I need.

    Please Login or Register  to view this content.
    In my case truncated to

    Please Login or Register  to view this content.
    Last edited by Orada; 07-29-2013 at 07:57 PM.

+ 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. Column Name is Perplexing
    By 2709236 in forum Access Tables & Databases
    Replies: 4
    Last Post: 01-12-2012, 07:20 AM
  2. Problem with date range lookups and calculations
    By miles_muso in forum Excel General
    Replies: 8
    Last Post: 10-05-2009, 05:23 AM
  3. Perplexing Macro Issue
    By Digger442 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-20-2007, 09:59 AM
  4. Perplexing Excel question
    By Valiantlyon in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-15-2007, 11:15 PM
  5. [SOLVED] Perplexing sheets.
    By ben in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-13-2005, 03:05 PM

Tags for this Thread

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