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.

Visit Date 2018Visit Date 2019Year
3/16/2018
8/23/2019
8/23/2019
8/23/2019
6/12/2019
6/12/2019
6/12/2019
6/12/2019
6/12/2019
1/25/2019
5/24/20181/9/2019
7/27/2018

<colgroup><col span="2"><col></colgroup><tbody>
</tbody>
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
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
You are welcome.
 
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:

Date and Time Reviewed (Date Supervisor Reviewed) Time Reviewed AM/PM Reviewed
12/28/2017 0:261/0/1900 0:2612:26 AM
05/23/2018
12:00 M
#VALUE!#VALUE!

<colgroup><col><col><col></colgroup><tbody>
</tbody>


The calculations I have are:

Date and Time Reviewed (Date Supervisor Reviewed) Time Reviewed AM/PM Reviewed
12/28/17 =TIME(HOUR(U2),MINUTE(U2), SECOND(U2)) =IF(V2=0,"",TIME(HOUR(U2),MINUTE(U2),SECOND(U2)))
05/23/2018 12:00 M=TIME(HOUR(U11438),MINUTE(U11438), SECOND(U11438)) =IF(V11438=0,"",TIME(HOUR(U11438),MINUTE(U11438),SECOND(U11438)))

<colgroup><col><col><col></colgroup><tbody>
</tbody>

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,213,561
Messages
6,114,316
Members
448,564
Latest member
ED38

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