convert function (from date to year)

srananmeitie

New Member
Joined
Feb 3, 2005
Messages
16
I am using CONVERT to change a date (ie. 14-march 1996) to the year (1996). I am using: CONVERT (cellwithdate, "day", "yr").
For the example date above, it returns 1900 as the result.

Can anyone please tell me what I am doing wrong?

thanks!
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Why not just use the YEAR function?

=YEAR(cellwithdate)

This does not need the Analysis Toolpak, as CONVERT does.
 
Upvote 0
I tried using the Year function and it returns an incorrect year.
For example, A1 = 10/25/1996 (formatted to display as Oct-25-1996)
Year(A1) will result in 1905.

Is there something wrong with how my date is stored? I tried formatting the date as "general", so that it shows a numeric value, but it still returns the wrong year.
 
Upvote 0
It would seem you are not entering it as a true date. The YEAR function shall work when you convert the date to an actual number (Excel recognized date {serial} ). If not, you can use this formula ..

=--RIGHT(SUBSTITUTE(C7,"-","|",2),LEN(C7)-FIND("|",SUBSTITUTE(C7,"-","|",2),1))


HTH
 
Upvote 0
srananmeitie said:
I tried using the Year function and it returns an incorrect year.
For example, A1 = 10/25/1996 (formatted to display as Oct-25-1996)
Year(A1) will result in 1905.

Is there something wrong with how my date is stored? I tried formatting the date as "general", so that it shows a numeric value, but it still returns the wrong year.

When you activate A1, what displays in the formula bar?
 
Upvote 0
A1 displays "10/25/1996" in the formula bar.
Originally, the value of A1 comes from a VLOOKUP function, I copied the outcome of that function (paste special: value only).
 
Upvote 0
Have you tried my formula above? Just change out / for - .

...


=--RIGHT(SUBSTITUTE(C7,"/","|",2),LEN(C7)-FIND("|",SUBSTITUTE(C7,"/","|",2),1))


Note: C7 was just the cell I tested the formula in, you would need to replace every reference to it with the cell of yours in question.
 
Upvote 0

Forum statistics

Threads
1,203,728
Messages
6,057,008
Members
444,902
Latest member
ExerciseInFutility

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
Back
Top