Years

lehy2002

New Member
Joined
Nov 3, 2016
Messages
22
I need to calculate the year for the following data. What I want to know for the year column is if there is a date in the Visit date 2018 column bring back 2018 in the year column, if there is a date in the visit date 2019 it will bring back 2019 in the year column, if there is a date in both, it will bring back 2018/2019 in the year column and if there are no dates in either of the visit columns the year column will be blank. I hope that makes sense. Thank you.

[TABLE="width: 344"]
<colgroup><col span="2"><col></colgroup><tbody>[TR]
[TD]Visit Date 2018[/TD]
[TD]Visit Date 2019[/TD]
[TD]Year[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]3/16/2018[/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]8/23/2019[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]8/23/2019[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]8/23/2019[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]6/12/2019[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]6/12/2019[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]6/12/2019[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]6/12/2019[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]6/12/2019[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]1/25/2019[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]5/24/2018[/TD]
[TD]1/9/2019[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]7/27/2018[/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
For row 2, place this in cell C2 and copy down for all rows.
Code:
=IF(AND(A2>0,B2>0),YEAR(A2)&"/"&YEAR(B2),IF(A2>0,YEAR(A2),IF(B2>0,YEAR(B2),"")))
 
Upvote 0
This will give back a value error if it is 12 M or 12N. how do I get rid of that and give me the correct info?
 
Upvote 0
Or try:

=SUBSTITUTE(TRIM(TEXT(A2,"yyyy;;;")&" "&TEXT(B2,"yyyy;;;"))," ","/")
 
Upvote 0
This will give back a value error if it is 12 M or 12N. how do I get rid of that and give me the correct info?
I do not understand what you are saying.
You have dates or blanks in your two columns, right?
What is is "12 M" or "12N" then?
 
Upvote 0
I do not understand what you are saying.
You have dates or blanks in your two columns, right?
What is is "12 M" or "12N" then?

Oops - working on two sheets. For this one, I have the calculation
TIME(HOUR(U11438),MINUTE(U11438), SECOND(U11438))

to pull the time out of a date/time formatting in a cell. However, if the time is 12M (midnight) or 12N (noon) it gives a value error instead of the time. See what I have below:

[TABLE="width: 338"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]Date and Time Reviewed (Date Supervisor Reviewed) [/TD]
[TD] Time Reviewed [/TD]
[TD] AM/PM Reviewed[/TD]
[/TR]
[TR]
[TD]12/28/2017 0:26[/TD]
[TD]1/0/1900 0:26[/TD]
[TD]12:26 AM[/TD]
[/TR]
[TR]
[TD]05/23/2018
12:00 M[/TD]
[TD]#VALUE![/TD]
[TD]#VALUE!
[/TD]
[/TR]
</tbody>[/TABLE]


The calculations I have are:

[TABLE="width: 934"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]Date and Time Reviewed (Date Supervisor Reviewed) [/TD]
[TD] Time Reviewed[/TD]
[TD] AM/PM Reviewed[/TD]
[/TR]
[TR]
[TD]12/28/17 [/TD]
[TD]=TIME(HOUR(U2),MINUTE(U2), SECOND(U2))[/TD]
[TD] =IF(V2=0,"",TIME(HOUR(U2),MINUTE(U2),SECOND(U2)))[/TD]
[/TR]
[TR]
[TD]05/23/2018 12:00 M[/TD]
[TD]=TIME(HOUR(U11438),MINUTE(U11438), SECOND(U11438)) [/TD]
[TD] =IF(V11438=0,"",TIME(HOUR(U11438),MINUTE(U11438),SECOND(U11438)))[/TD]
[/TR]
</tbody>[/TABLE]

Hope this makes sense
 
Upvote 0
To pull just the time out of any Date/Time value, you can simply use:
Code:
[COLOR=#333333]=U11438-TRUNC([/COLOR][COLOR=#333333]U11438)
[/COLOR]
as Date/Times are actually stored in Excel as numbers, specifically the number of days since 1/0/1900, with a custom format on it (can see this easily by changing any valid DateTime entry to General format).
So Dates are the whole number, and Time is just the fractional piece. So you just have to get the fraction if you want the time only.

But I don't see what any of this has to do with your original question?
I need to calculate the year for the following data. What I want to know for the year column is if there is a date in the Visit date 2018 column bring back 2018 in the year column, if there is a date in the visit date 2019 it will bring back 2019 in the year column, if there is a date in both, it will bring back 2018/2019 in the year column and if there are no dates in either of the visit columns the year column will be blank. I hope that makes sense. Thank you.
Did you morph into a totally separate question?
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,264
Members
452,627
Latest member
KitkatToby

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