Subtract a number of days from a date included in a string text, resulting another date

vladimiratanasiu

Active Member
Joined
Dec 17, 2010
Messages
346
Office Version
  1. 2021
  2. 2019
Platform
  1. Windows
Hello!

I have a table with data, regarding products of a factory, as shown in the link Date.xlsx. The column A has information about every lot of products, formatted as text. Some cells have only the date, other ones have included also the number of the lot, delimitated by the "/" symbol. The column B has cells with number of days to be subtracted from the cells of column A. In the column C, I need the number of days to be subtracted from the date of string text, resulting the final date shown as example in cells C2, C3, C8 etc. What's the right formula, to get the necessary results? P.S. Even if some dates are formatted like 17/04/2022, ignore them and consider the final formula taking into account only date formatted as 17.04.2022

Thank you!
 
Last edited:

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hi Vladimiratansiu

Could you please check if the below formula works?

=IF(MID(A2,11,1)="/",TEXT(SUBSTITUTE(LEFT(A2,10),".","/")+0-B2,"DD/MM/YYYY")&RIGHT(A2,2),SUBSTITUTE(LEFT(A2,10),".","/")+0-B2)

Regards

Ian
 
Upvote 0
Hi Vladimiratansiu

Could you please check if the below formula works?

=IF(MID(A2,11,1)="/",TEXT(SUBSTITUTE(LEFT(A2,10),".","/")+0-B2,"DD/MM/YYYY")&RIGHT(A2,2),SUBSTITUTE(LEFT(A2,10),".","/")+0-B2)

Regards

Ian
Thank you for the quick response! In the cells C1:C7, C14:C16 and C25, the content is very good. The other results include also number of the lots (/1, /2, /3 etc). Could you adjust the formula in order do remove that sequence and keep only the date? Thank you!
 
Upvote 0
Thank you for the quick response! In the cells C1:C7, C14:C16 and C25, the content is very good. The other results include also number of the lots (/1, /2, /3 etc). Could you adjust the formula in order do remove that sequence and keep only the date? Thank you!
Try this formula

=SUBSTITUTE(LEFT(A2,10),".","/")+0-B2

Regards

Ian
 
Upvote 0
Solution

Forum statistics

Threads
1,214,786
Messages
6,121,546
Members
449,038
Latest member
Guest1337

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