Convert text value to Short Time (1 Viewer)

JH40

Registered User.
Local time
Today, 12:22
Joined
Sep 16, 2010
Messages
100
I am going absolutely awol trying to find the formula... I had it in a query, but the db corrupted before I saved the query (Access 2010--no surprise)... I am trying to convert a text field to a time value. I had used something like the following and it worked great! Now I can't recall how to write it.

CTime([date],"@@\:mad:@")

I know that is wrong, but it looks somewhat similar. TimeValue, Format and Convert do not work for some reason.

Thank you...
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 12:22
Joined
Aug 30, 2003
Messages
36,137
I don't know that there's any such function. If you're trying to convert text:

?timevalue("8:30")
8:30:00 AM
 

JH40

Registered User.
Local time
Today, 12:22
Joined
Sep 16, 2010
Messages
100
Let me clarify by example above. I indicate "date" in error. There is no "date" data. The raw text value is for example:

900

and needs to show as 9:00 AM

no date is involved.
 

JH40

Registered User.
Local time
Today, 12:22
Joined
Sep 16, 2010
Messages
100
Thanks for your input Paul. I actually found it! Here it is in case you ever need it. Works so well...

CDate(Format([admit time],"@@\:mad:@"))
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 12:22
Joined
Aug 30, 2003
Messages
36,137
Glad you found your solution.
 

nyaworld

Registered User.
Local time
Today, 14:22
Joined
Nov 18, 2015
Messages
24
Thanks for your input Paul. I actually found it! Here it is in case you ever need it. Works so well...

CDate(Format([admit time],"@@\:mad:@"))

I put this into my query and when I run it, I get "#Error".

Real Time: CDate(Format([Start Time],"@@\@@"))

The value I'm trying to convert is a text string. So, 17:30:00.000 is supposed to be 5:30PM, but I can't convert it. I got excited when I saw this post, but it doesn't work.

I'm using Access 2013 if it matters. :banghead:
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 12:22
Joined
Aug 30, 2003
Messages
36,137
If your value is text, try reversing the functions. You want to convert it to a date/time value, then format it.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:22
Joined
May 7, 2009
Messages
19,246
you missed a colon in your format.
 

nyaworld

Registered User.
Local time
Today, 14:22
Joined
Nov 18, 2015
Messages
24
you missed a colon in your format.


You are right, I did. I got all excited and tried it the correct way and STILL got an error message:

Real Time: CDate(Format([Start Time],"@@\:mad:@"))

#Error

:(
 

nyaworld

Registered User.
Local time
Today, 14:22
Joined
Nov 18, 2015
Messages
24
If your value is text, try reversing the functions. You want to convert it to a date/time value, then format it.

How do I convert the field (a text value) into a time value? Can't I do this in a query? If I can, how? I have tried all sorts of functions and I still get #Error.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 12:22
Joined
Aug 30, 2003
Messages
36,137
Like I suggested in your other thread:

?cdate("17:00:00")
5:00:00 PM
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:22
Joined
May 7, 2009
Messages
19,246
TimeValue(Format([Start Time], "00\:00")) or
CDate(Format([Start Time], "00\:00"))
 

Users who are viewing this thread

Top Bottom