Enter year alone in cell.

jblevins

Active Member
Joined
Sep 2, 2013
Messages
250
Office Version
  1. 2003 or older
I want to enter the year only in a cell and use it in the DATE function, but it always returns 1905.
Excel Formula:
Enter 2023 in A1 as text
DATE(YEAR(A1),MONTH(B1),DAY(C1))
:
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
If you are just entering the numbers in cells A1, B1, and C1, then your formula should just be:
Excel Formula:
=DATE(A1,B1,C1)
as the YEAR, MONTH, and DAY function are meant to be applied to existing date values, not standalone numbers like 2023.
 
Upvote 0
This return #NUM:
Code:
=DATE(Jul!F8,Jul!H1,Jul!F7)

The actual function that works that I want to replace the year in:
Code:
=DATE(YEAR(Jul!F8),MONTH(Jul!H1),DAY(Jul!F7))
 
Upvote 0
OK, since you are entering in the year only, but the MONTH and DATE are coming from another date (which was not clear from your original post), you would just use:
Excel Formula:
=DATE(Jul!F8,MONTH(Jul!H1),DAY(Jul!F7))

Note: This all makes more sense when you understand how dates work in Excel.
Dates are really just numbers, with special date formats applied to them.
The number is just the number of days since 1/0/1900. You can see this easily by entering any date into Excel, and changing the format of that cell to "General".
This number is how Excel see dates.

So, if you enter the number 2023 in a cell, and then change it to a date format, you can see it represents the date: 7/15/1905.
That is why when you apply the YEAR function to that value, it returns 1905.
You do NOT want the year value from that date, you want to use that number, straight up, as the year. So you would not apply the YEAR function to it.

Make sense?
 
Upvote 0
Solution
Sorry just spotted did not work years jumped up
 
Upvote 0
OK, since you are entering in the year only, but the MONTH and DATE are coming from another date (which was not clear from your original post), you would just use:
Excel Formula:
=DATE(Jul!F8,MONTH(Jul!H1),DAY(Jul!F7))

Note: This all makes more sense when you understand how dates work in Excel.
Dates are really just numbers, with special date formats applied to them.
The number is just the number of days since 1/0/1900. You can see this easily by entering any date into Excel, and changing the format of that cell to "General".
This number is how Excel see dates.

So, if you enter the number 2023 in a cell, and then change it to a date format, you can see it represents the date: 7/15/1905.
That is why when you apply the YEAR function to that value, it returns 1905.
You do NOT want the year value from that date, you want to use that number, straight up, as the year. So you would not apply the YEAR function to it.

Make sense?
The answer seems to be that I had the cell formatted wrong (changed it to General) where the year is entered and also had to remove the YEAR function.
 
Upvote 0
The answer seems to be that I had the cell formatted wrong (changed it to General) where the year is entered and also had to remove the YEAR function.
Yep, just like I said.

Does my explanation make sense?
If you understand it, it explains the reasoning for this.
 
Upvote 0
Removing YEAR was a help, thanks...
But do you understand why you had to do this?

I took the time to try to explain why this is, and how dates work in Excel.
Did you read that part, and understand what I was explaining - how dates are stored in Excel?

Quote from previous reply:
Note: This all makes more sense when you understand how dates work in Excel.
Dates are really just numbers, with special date formats applied to them.
The number is just the number of days since 1/0/1900. You can see this easily by entering any date into Excel, and changing the format of that cell to "General".
This number is how Excel see dates.

So, if you enter the number 2023 in a cell, and then change it to a date format, you can see it represents the date: 7/15/1905.
That is why when you apply the YEAR function to that value, it returns 1905.
You do NOT want the year value from that date, you want to use that number, straight up, as the year. So you would not apply the YEAR function to it.

If there is any part of this you do not understand, please let me know.
 
Upvote 0

Forum statistics

Threads
1,214,975
Messages
6,122,538
Members
449,088
Latest member
RandomExceller01

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