Hi,
Please can anyone explain why using this formula works fine for the current year but not the prior year?
The format of column A is general, being an import from an external data source.
Calculating dates (prior year)
-
- 5StarLounger
- Posts: 1185
- Joined: 24 Jan 2010, 12:02
- Location: Wales, UK.
Calculating dates (prior year)
You do not have the required permissions to view the files attached to this post.
Nathan
There's no place like home.....
There's no place like home.....
-
- Administrator
- Posts: 78650
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Calculating dates (prior year)
The formula only works "fine" for the current month - look at the result in row 3! The formula uses the date format yyyymmdd as a number, e.g. today is 20110212 i.e. 20,110,212 = twenty million one hundred and ten thousand two hundred and twelve. This is not a number of days in any meaningful sense of the word.
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 1185
- Joined: 24 Jan 2010, 12:02
- Location: Wales, UK.
Re: Calculating dates (prior year)
I see what you mean.
Is there a way to convert A1 to a meaningful value in order to calculate?
Is there a way to convert A1 to a meaningful value in order to calculate?
Nathan
There's no place like home.....
There's no place like home.....
-
- Administrator
- Posts: 78650
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Calculating dates (prior year)
Yes, for example
=DATE(LEFT(A1,4),MID(A1,5,2),RIGHT(A1,2))
or
=DATE(TRUNC(A1/10000),MOD(A1/100,100),MOD(A1,100))
=DATE(LEFT(A1,4),MID(A1,5,2),RIGHT(A1,2))
or
=DATE(TRUNC(A1/10000),MOD(A1/100,100),MOD(A1,100))
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 1185
- Joined: 24 Jan 2010, 12:02
- Location: Wales, UK.
Re: Calculating dates (prior year)
Great, Thanks Hans.
=VALUE(TODAY())-DATE(LEFT(A1,4),MID(A1,5,2),RIGHT(A1,2))
..... appears to be accurate.
=VALUE(TODAY())-DATE(LEFT(A1,4),MID(A1,5,2),RIGHT(A1,2))
..... appears to be accurate.
Nathan
There's no place like home.....
There's no place like home.....
-
- Administrator
- Posts: 78650
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Calculating dates (prior year)
You don't need VALUE here.
=TODAY()-DATE(LEFT(A1,4),MID(A1,5,2),RIGHT(A1,2))
should work - if Excel formats the result as a date, just clear the formatting (or set the number format to General).
=TODAY()-DATE(LEFT(A1,4),MID(A1,5,2),RIGHT(A1,2))
should work - if Excel formats the result as a date, just clear the formatting (or set the number format to General).
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 1185
- Joined: 24 Jan 2010, 12:02
- Location: Wales, UK.
Re: Calculating dates (prior year)
Nathan
There's no place like home.....
There's no place like home.....