Convert large string into DATE/Time Field in MS ACCESS Query

yomero

Active Member
Joined
May 14, 2008
Messages
257
Hi,
I have tried many solutions in this forum, however I am still stuck.
I am linking a large CSV file into MS ACCESS. All fields are TEXT. I tried linking the Date field as Date/Time but was not able to accomplish it.

The example is: 2017-03-19 04:55:38.539038

Using Builder expressions I am able to separate into 2 fields using
- DATE_Only =DATEVALUE(LEFT(DATE,10) )=
2017-03-19
- TIME = TIMEVALUE(RIGHT(LEFT(DATE,19),9))=
04:55:38

[FONT=arial, sans-serif]I join them using the FORMATDATETIME function however the resulting field is not a DATE/TIME field.[/FONT]
2017-03-19 04:55:38

[FONT=arial, sans-serif]Thanks, for your help.[/FONT]
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Try

Code:
Sub testTextDate()
Dim strDateTime As String
Dim dtDate As Date, dtTime As Date
Dim dtBoth As Date
strDateTime = "2017-03-19 04:55:38"
dtDate = DateValue(Left(strDateTime, 10))
dtTime = TimeValue(Right(Left(strDateTime, 19), 8))
dtBoth = dtDate + dtTime
End Sub
 
Upvote 0
Possibly import rather than link. Then you can work with the data in MSAcess directly as a field in a database table.
 
Upvote 0

Forum statistics

Threads
1,221,707
Messages
6,161,411
Members
451,704
Latest member
rvan07

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