+ Reply to Thread
Results 1 to 6 of 6

Subtracting Dates Macro Issue

  1. #1
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Subtracting Dates Macro Issue

    I have the below code that subtracts a date that I type into B3 (the cell is formatted dd/mm/yyyy) from the date in cell B1 which is todays date. If I have tomorrows date in B3 the result returned is 0 when it should be 1. Why is this?
    Please Login or Register  to view this content.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Subtracting Dates Macro Issue

    Now returns the date and time.

    The formula returns 0.19943044 for me, which is about 4 ¾ hours.

    Have you've formatted the cell with the formula so that decimals won't show.

  3. #3
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Subtracting Dates Macro Issue

    I have X3 formatted to Number with 0 decimal places. So the above macro returns 0 in X3. Answer should be 1 when taking tomorrows date from todays though......

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Subtracting Dates Macro Issue

    The answer isn't 1 though, you are subtracting a date from a date/time, so you will be left with a time portion.

  5. #5
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Subtracting Dates Macro Issue

    Ah I see what you mean. So is there a formula I can use in cell B1 that will just display todays date?

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Subtracting Dates Macro Issue

    Use TODAY().

+ 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