Skip to main content
Solved

Time of Day field values are not in 24-hour format in Pipelines


Frontman
Forum|alt.badge.img+4

Hi all. I think I found a bug with Pipelines where using a Time of Day field isn't in 24-hour format even when you set the field settings to 24-hour. 

Can anyone think of a possible workaround?

Most APIs use 24-hour format so having Pipelines only output in North American format makes it impossible to pass along the correct time format.

Steps to reproduce:

  1. Create a Time of Day field.
  2. In field settings > Value display, enable 24-hour clock.
  3. Create a pipeline that sends a value in this field.
  4. Pipelines outputs the field in North American time format (for example, 5:00 PM), instead of 24-hour format (ex: 17:00).

I tried using Jinja to reformat to 24-hour, but Pipelines doesn't support the jinja filters needed to re-format to 24-hour time. Here's the Jinja expression I tried:

{{ time-field|replace(" AM", "").|replace(" PM", "")|stringptime("%I:%M")|strftime("%H:%M") }}

Best answer by DougHenning1

Easiest would be to parse the field then format:

{{ (time.parse(a.time_of_day)).strftime('%H:%M') }}

Above will output 23:30 if a.time_of_day is 11:30 PM

View original
This topic has been closed for replies.

Forum|alt.badge.img+11

QuickBase supports jinja filters in pipeline 
https://helpv2.quickbase.com/hc/en-us/articles/4471048652308-Using-Jinja-in-Quickbase-Pipelines

stringptime is not supported 

chatGPT is notorious for including python function. I highly recommend taking the jinja course from QuickBase Junkie which has detailed bible. 

The easiest way to do this is going to be a formula , you can use a combination of parts to extract AM PM , then another part to get hour and minute function to convert to military time and then simply copy that . 

If you are bent on jinja to achieve this , this is something which was cooked chatGPT (again thanks to QuickBase Junkie bible- I could correct chatgpt), I tested this with 4:30 PM and 11:30 PM.

{% set time_str = "11:30 PM" %}
{% set split_ampm = time_str.split(' ') %}
{% set split_time = split_ampm[0].split(':') %}
{% set hour_val = split_time[0] %}
{% set minute_val = split_time[1]|default(0) %}
{% set am_pm = split_ampm[1] %}
{% set military_hour = hour_val|int %}
{% if "PM" in am_pm %}
    {% if military_hour != 12 %}
        {% set military_hour = military_hour + 12 %}
    {% endif %}
{% endif %}
{% set military_time_str = "%02d:%02d" % (military_hour, minute_val|int) %}
{{ military_time_str }}

 


Forum|alt.badge.img+6
  • Quickbase Staff
  • Answer
  • April 30, 2024

Easiest would be to parse the field then format:

{{ (time.parse(a.time_of_day)).strftime('%H:%M') }}

Above will output 23:30 if a.time_of_day is 11:30 PM


Frontman
Forum|alt.badge.img+4
  • Author
  • Registered
  • May 2, 2024

That worked. Thanks Doug!