• 0

# Time format

## Question

Hi, I have this calculation formula:

CASE WHEN CONVERT(VARCHAR, [@field:Date], 108) = '00:00:00' THEN ' ' ELSE CONVERT(VARCHAR, [@field:Date], 108) END

I need to do is get the format to be AM/PM. Right now the result is 19:00:00 it should be 7:00 AM. How to achieve that?

## Recommended Posts

• 0

Hi @Barbie

If you want to have that format, please use the formula below:

CASE WHEN CONVERT(VARCHAR, [@field:Date], 108) = '00:00:00' THEN ' ' ELSE CONVERT(VARCHAR,CAST('[@field:Date]' AS TIME),100) END

I hope this works now.

- Batchini

##### Share on other sites

• 0

Thank you @Batchinithat worked. But how can we add the space between minute and AM/PM?

##### Share on other sites

• 0

That's great, @Barbie. You can use this formula instead:

REPLACE(REPLACE(CONVERT(varchar(15), CAST([@field:Date] AS TIME), 100), 'P', ' P'), 'A', ' A')

I hope this satisfies your wrkflow now.

##### Share on other sites

• 0

Just to add in the workaround above, you may consider reviewing these links:

##### Share on other sites

• 0
On 3/30/2021 at 10:42 AM, Barbie said:

Hi, I have this calculation formula:

CASE WHEN CONVERT(VARCHAR, [@field:Date], 108) = '00:00:00' THEN ' ' ELSE CONVERT(VARCHAR, [@field:Date], 108) END

I need to do is get the format to be AM/PM. Right now the result is 19:00:00 it should be 7:00 AM. How to achieve that?

Hi @Barbie,

You can also change the formatting of the result of this Formula. It is only applicable if you are using  a DataPage. However, if it is in the Table level, you may use the other solution provided in this thread.

##### Share on other sites

• 0

In addition to @LittleMsGinger's suggestion, here is an additional resource for you. It is about field formatting.

-  LOEY

##### Share on other sites

• 0

Hi - For Time only fields, you can check this new forum post:

##### Share on other sites

• 0

Hi! Caspio now offers integration with OpenAI, so you can use extensions to leverage AI to update your data based on a prompt. Here's a sample use case to get the time only based on the provided Date/Time field.

Request:
Get the time in "[@field:Date_Submitted]" and change it to 12-hr time.
Determine if it is AM or PM.
Return only the final result in the format of:
HH:MM AM or PM

Result:

Change the 'Date_Submitted' field to your right field name.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.