Forum Discussion

ScottDye's avatar
ScottDye
Qrew Trainee
3 months ago

Pipeline Jinja based on current timestamp

I'm trying to build a pipeline that runs hourly, to perform an API call. However, I would like for the same pipeline to perform a second action once per day, at a specific hour (when the hourly run happens in the 6:00AM hour).

I understand to build an if statement as so:

IF [expression (advanced)] evaluates to TRUE
[____________________________________]

and I know that the Jinja for "now" is {{time.now}}

How would I build the expression that returns true only if the current time is within the 6:00AM hour?



------------------------------
Scott Dye
------------------------------

5 Replies

  • I forgot to add, this would need to trigger TRUE within the 6:00 hour only M-F, not weekends.



    ------------------------------
    Scott Dye
    ------------------------------
    • ChayceDuncan's avatar
      ChayceDuncan
      Qrew Captain

      You can use strftime with something like this so it's nice and easy to read: 

      %w returns the weekday index with Sunday = 0 and Saturday = 6 so those are omitted, and then %-H returns the current 24 hour value of the current time. Keep in mind that Pipelines runs on UTC time for conversions so you need to convert 6:00 AM to UTC time for your filter. 6AM EST is 11AM UTC so you would put 11 instead of 19 from my screenshot. 



      ------------------------------
      Chayce Duncan
      ------------------------------
      • ScottDye's avatar
        ScottDye
        Qrew Trainee

        This is great. Thanks! For reference if anyone tries this, the 'weekday' check also assumes UTC time, so the start of the day does not match the start of my day. In my case, that was not really a big deal, but wanted to mention it. 



        ------------------------------
        Scott Dye
        ------------------------------