Convert text formatted date to date format

susom

Board Regular
Joined
Aug 3, 2011
Messages
55
Office Version
  1. 365
Platform
  1. Windows
How do I format this text "Nov-14-2022" to date format? I have tried the DATEFORMAT function to no avail--it results in a #VALUE!

Background:
I have data that coming out of a screen query that has a long string of text with a date range imbedded in it. This is the format: " Nov-14-2022 to Jan-09-2023". I am able to use text functions to pull the begging and ending dates in this format: "Nov-14-2022" and "Jan-09-2023" in two separate cells. I would now like to calculate the number of days between the two dates, but as they are formatted as text I cannot. Feels like it should be easy, but a simple google search provided now help.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
The method will depend on which version of Excel you are using?

Also are you looking to do this with VBA or Formula?
 
Upvote 0
Excel version 2302. A formula would be ideal.
 
Upvote 0
To convert your text string into a date value, try
Excel Formula:
=--SUBSTITUTE(B2,"-",", ",2)
To calculate the number of days between two dale-like text strings, try
Excel Formula:
=SUBSTITUTE(C2,"-",", ",2)-SUBSTITUTE(B2,"-",", ",2)
 
Upvote 0
Solution
HA! Thank you. Your solution is so much simpler that this cob job set of formulas that I finally managed to make work.

=CONCATENATE((VLOOKUP(MID((LEFT((RIGHT(F9,(LEN(F9))-(FIND("e: ",F9)+2))),11)),1,3),$K$9:$L$20,2,FALSE))&"/"&MID((LEFT((RIGHT(F9,(LEN(F9))-(FIND("e: ",F9)+2))),11)),5,2)&"/"&MID((LEFT((RIGHT(F9,(LEN(F9))-(FIND("e: ",F9)+2))),11)),8,4))
 
Upvote 0
Another option that won't be restricted by locale,
Book1
AB
1Nov-14-202214/11/2022
2Jan-09-202309/01/2023
Sheet1
Cell Formulas
RangeFormula
B1:B2B1=DATE(RIGHT(A1,4),MONTH("1"&LEFT(A1,3)),MID(A1,5,2))
 
Upvote 0

Forum statistics

Threads
1,215,094
Messages
6,123,071
Members
449,092
Latest member
ipruravindra

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