How to convert a string from Json to Ms Access date & time (1 Viewer)

nector

Member
Local time
Today, 13:07
Joined
Jan 21, 2020
Messages
368
Hello there!

Can someone help me to convert this date/time string to normal date:

String : 20230626121231

I want a function to convert the above string to look like this : 2023/06/26 12:12:31

Kindly try it in Ms Access before posting , I tried this function below it failed:

Format(20230626121231, "mm/dd/yyyy hh:hh:ss am/pm")
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:07
Joined
Oct 29, 2018
Messages
21,473
Did you try enclosing the string with double quotes?
 

nector

Member
Local time
Today, 13:07
Joined
Jan 21, 2020
Messages
368
Actual that is coming from a control called invoicedate
 

Josef P.

Well-known member
Local time
Today, 12:07
Joined
Feb 2, 2023
Messages
826
Code:
DateValue = CDate(Format("20230626121231", "@@@@-@@-@@ @@:@@:@@"))
xyz = Format(DateValue, "mm\/dd\/yyyy hh:nn:ss am/pm")
 

nector

Member
Local time
Today, 13:07
Joined
Jan 21, 2020
Messages
368
Josef P.

The code is giving an error called overflow runtime 6:

Code:
Me.txtEsd = Format(DLookup("EsDTime", "tblEfdReceipts", "INVID =" & [InvoiceID]), "mm/dd/yyyy hh:hh:ss am/pm")
 
Last edited:

jdraw

Super Moderator
Staff member
Local time
Today, 06:07
Joined
Jan 23, 2006
Messages
15,379
nector,

This format is incorrect "mm/dd/yyyy hh:hh:ss am/pm"
should be nn for minutes
 

Josef P.

Well-known member
Local time
Today, 12:07
Joined
Feb 2, 2023
Messages
826
202306261231 is not a number corresponding to a date value. Therefore you can't convert it with "mm/dd/yyyy ...".

Have you tried the code I gave you?
 

nector

Member
Local time
Today, 13:07
Joined
Jan 21, 2020
Messages
368
nector,

This format is incorrect "mm/dd/yyyy hh:hh:ss am/pm"
should be nn for minutes
nector,

This format is incorrect "mm/dd/yyyy hh:hh:ss am/pm"
should be nn for minutes


Code:
Me.txtEsd = Format(DLookup("EsDTime", "tblEfdReceipts", "INVID =" & [InvoiceID]), "mm/dd/yyyy hh:nn:ss am/pm")

Im still getting the same message


Runtime 6 overflow.png
 

jdraw

Super Moderator
Staff member
Local time
Today, 06:07
Joined
Jan 23, 2006
Messages
15,379
See Josef's answer in #7
 

Users who are viewing this thread

Top Bottom