Link to home
Start Free TrialLog in
Avatar of RUA Volunteer2?
RUA Volunteer2?Flag for United States of America

asked on

how to identify the year in a datetime stamp and replace the value with a new year. If Year in datetime = 2004 then replace year with 2018

How do you identify the year in a column in excel and build an If Then Else statement to change the year in that column?
So if the excel file included has a date field with a time stamp in it. How do I find the year and then determine if the year is say 2004 then switch it to 2018 else if 2003 then 2017 etc.

I found this part of the equation in a youtube video but I cannot seem to google the right words for finding the year for the if then else statement? Any thoughts are much appreciated. I got parts of it but keep failing at the correct sequence. If written in the English language it would look like this:
If YEAR(DateTime) = "2004" then Replace YEAR with  "2018" else if ....Orders.xlsx
Avatar of Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj)
Flag of India image

What I am missing here? The file you uploaded doesn't have any datetime column, have you uploaded the correct file?
Avatar of RUA Volunteer2?

ASKER

I messed up and placed the wrong file in my apologies this one has them.
In the latest file, you have three date columns, which column you are referring to?

Explain the logic taking some date cells and let me know what would be desired output?
If required, populate a new column called Desired output and mock up the desired output manually for some of the date cells which follows your logic to show what end result you are trying to achieve.
ASKER CERTIFIED SOLUTION
Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you had to nest them as some have and some don't have time stamp?


=DATE(YEAR(E2)+14,MONTH(E2),DAY(E2))+TIME(HOUR(E2),MINUTE(E2),SECOND(E2))
Also it just returns the date only not the time. It does have an AM & PM (the meridiem) on the end of it if that might be the problem?
Can you set up such an example?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great stuff thank you. Sorry I messed up the file the first time. I did not pay attention to the variety of the differences in the times stamps which could change the formula.