Field Date Time

Good morning,
I need a solution regarding the DateTime Field.
If you create a DateTime field and put TIME ONLY on it, it is expected that only the Time would be stored in the Glide database.
In fact it only shows the time but saves the full date.
This is causing some logic issues in the application.
A practical example follows.
A business has a defined opening and closing time.
Example:
Today’s Date: July 18, 2023
In the GLIDE worksheet I create 3 fields, all Date Time (Time Only).

Open - 8:00 (July 18, 2023)

Close - 16:00 (July 18, 2023)

Now - 11:00 (July 18, 2023)
To check whether NOW is within the range and define whether the company is OPEN or CLOSE, use the following query.

IF OPEN>NOW = OPEN
IF CLOSE< NOW = OPEN
ELSE = CLOSE
This logic works perfectly as long as the day is July 18, 2023.
When the day changes, logic no longer works.
Example:
Today’s Date: July 19, 2023
In the spreadsheet

Open - 8:00 (July 18, 2023)

Close - 16:00 (July 18, 2023)

Now - 11:00 (July 19, 2023)

In other words, when selecting TIME ONLY in a DATE TIME field, the rest of the date cannot be hidden because it causes a serious error in the logic of the person creating it.
Thank you very much for a solution.
Lomanto

Setting the format is only cosmetic for display purposes. The underlying value is always preserved. This is expected behavior. Also, there is no such thing as a date column that only stores a time. Even if you could, you would be comparing to a date far in the past.

I think the easiest solution is to create two math columns to return the time in a numeric format. One for your existing date columns and one for ‘now’.

Like this:

HOUR(Date)*100+MINUTE(Date)

HOUR(Now)*100+MINUTE(Now)

2 Likes

I try it.
Thanks

1 Like