Covert text date to date format

TinaK

New Member
Joined
Dec 13, 2019
Messages
6
Office Version
2013
Platform
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#.
 

ranman256

Well-known Member
Joined
Jun 17, 2014
Messages
1,808
mid([field3],5,2) & "/" & Mid([field3],7,2) & "/" & Left([field3],4)
 

ranman256

Well-known Member
Joined
Jun 17, 2014
Messages
1,808
in query1, convert the dates.
then in Query2, use Q1 to do your date range.
 

TinaK

New Member
Joined
Dec 13, 2019
Messages
6
Office Version
2013
Platform
Windows
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.
 

JonXL

Active Member
Joined
Feb 5, 2018
Messages
257
Office Version
365, 2016
Platform
Windows
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.
 

TinaK

New Member
Joined
Dec 13, 2019
Messages
6
Office Version
2013
Platform
Windows
JonXL the above was only an example. I have dates from 2018 & 2019.
 

JonXL

Active Member
Joined
Feb 5, 2018
Messages
257
Office Version
365, 2016
Platform
Windows
JonXL the above was only an example. I have dates from 2018 & 2019.
So did you get this to work?
 

TinaK

New Member
Joined
Dec 13, 2019
Messages
6
Office Version
2013
Platform
Windows
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.
 

JonXL

Active Member
Joined
Feb 5, 2018
Messages
257
Office Version
365, 2016
Platform
Windows
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.
 

Forum statistics

Threads
1,082,138
Messages
5,363,351
Members
400,729
Latest member
Lisa McConachy

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top