Covert text date to date format

TinaK

New Member
Joined
Dec 13, 2019
Messages
6
Office Version
  1. 2013
Platform
  1. Windows
I have a table that is imported from a text file. The date from the text file is stored as "short text" in my access table. (2018012903:3913010100110201). I want to convert it to 01/29/2018. I have tried several different ways and nothing has worked. This is the closest I was able to get:
Expr1: Right([field3],2) & "/" & Mid([field3],7,2) & "/" & Left([field3],4)
Results
test1

Field3Expr1
2018012903:391301010011020101/29/2018
2018012807:211277011011040202/28/2018
2018012807:351278012011040202/28/2018
As you can see, the first one is correct, the others are not.

After I convert it to a date, I want to use "between #xx/xx/xx# and #xx/xx/xx#.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Thank you ranman. The first one works great. i created a second query and the results are blank. I used the expression field and used between #01/01/2019# and #11/30/2019# and nothing. I also only used 19 instead of 2019 and nothing.
 
Upvote 0
Combining ranman256's into the following query returned the correct results for me:

SQL:
select * from [dates]
where #1/28/2018# between cdate(mid([field3],5,2) & "/" & Mid([field3],7,2) & "/" & Left([field3],4)) and cdate(expr1)

ABE: The query you say you are trying to run should naturally return no results since all your dates in the sample data are in 2018.
 
Upvote 0
JonXL the above was only an example. I have dates from 2018 & 2019.
 
Upvote 0
JohnXL, I did find a way for it to work. I had to use "make a table query", format the field in that table to be able to pull out certain dates.

Thank you all so much for your help.
 
Upvote 0
For a single use that might be fine, but if doing this on a regular basis, I think your DB is going to get very bloated.

And honestly, I don't see why you would need to create a new table for this. If you nest ranman256's formula in a CDate() function, it should return exactly what you're looking for just in one query.
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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