Code To Subtract Date On Opening

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,488
Office Version
  1. 365
Platform
  1. Windows
I have a workbook that when I open it I would like the date in the column to be taken away from a year every time I open it and give result please.

13/12/2021 00:00​
276 Days
23/09/2021 00:00​
194 Days
11/10/2021 00:00​
213 Days
20/09/2021 00:00​
191 Days
30/07/2021 00:00​
140 Days

So in example above row 1, 13/12/2021 there are 276 days until 13/12/2022. I would like the code to work this out and give the new answer when opened. So if I open file in 2 days time it will automatically say 274 Days and so on....thanks.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

etaf

Well-known Member
Joined
Oct 24, 2012
Messages
4,671
Office Version
  1. 365
Platform
  1. MacOS
=DAYS(A1,today())
assuming the date is in A1
And will get the date of today and work out the days based on the date in A1 and todays date , when the spreadsheet is opened
Will get value when the date passes the date in A1

Book12
ABC
112/13/21276 Days276
Sheet1
Cell Formulas
RangeFormula
C1C1=DAYS(A1,TODAY())
 

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,488
Office Version
  1. 365
Platform
  1. Windows
Thanks that worked them out fine when entered now, I will look again tomorrow see if it changes. Thanks.
 

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,488
Office Version
  1. 365
Platform
  1. Windows
One other thing I cant get rid of the 00:00, I have tried text to columns but it remains e.g 13/12/2021 00:00
 

etaf

Well-known Member
Joined
Oct 24, 2012
Messages
4,671
Office Version
  1. 365
Platform
  1. MacOS

ADVERTISEMENT

change the format of the cell
probably set to
DD/MM/YYYY HH:MM
set to
DD/MM/YYYY
 

etaf

Well-known Member
Joined
Oct 24, 2012
Messages
4,671
Office Version
  1. 365
Platform
  1. MacOS

ADVERTISEMENT

you are welcome
 

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,488
Office Version
  1. 365
Platform
  1. Windows
=DAYS(A1,today())
assuming the date is in A1
And will get the date of today and work out the days based on the date in A1 and todays date , when the spreadsheet is opened
Will get value when the date passes the date in A1

Book12
ABC
112/13/21276 Days276
Sheet1
Cell Formulas
RangeFormula
C1C1=DAYS(A1,TODAY())
Upon opening I now have #NAME? and the same when I enter the formula again? Also the formula changed to =_xlfn.DAYS(A2,TODAY()) ?
 

Watch MrExcel Video

Forum statistics

Threads
1,129,936
Messages
5,639,084
Members
417,072
Latest member
JaimeDee

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top