Skip to main content
Question

Create a Table of all Sundays within a Year

  • October 18, 2023
  • 0 replies
  • 127 views

Forum|alt.badge.img+6

I have a parent table [year] and its child table is [week_ending_dates].

[year] ------------> [week_ending_dates]

A pipeline runs annually on 1 Jan of every year and creates the New Year's date of 1 JAN YYYY in the parent table record date field.

The parent record creation triggers another pipeline to populate the related child table [week_ending_dates] with every Sunday's date for that year. One date, one record. 

Well, that's where it ends for me....

I am seeking some insight into creating the pipeline loop that creates each Sunday's date, as a record for the parent year. Seeking full automation and trying to avoid any table imports or manual work.



------------------------------
v/r,
Chuck
------------------------------
This topic has been closed for replies.

Forum|alt.badge.img+9

Are you opposed to just doing a one time import? You can drag down the next 10 years of Sundays in Excel and just pre-load them now instead of building the Pipeline / testing it / monitoring it. 

You can just pre-load 5, 10, 15 years worth of data and if you don't want to see any of it just add a simple 'valid' checkbox to hide any futures you don't want and hide them via role security so that you don't have to worry about them being there they just re-appear when relevant. 



------------------------------
Chayce Duncan
------------------------------

Forum|alt.badge.img+6

I realize you already have an Excel solution, but if you want to use pipelines, this jinja will generate all the Sunday dates in a specified year separated by a semicolon:

{% set startDate = time.parse("1/1/2024") -%}
{% set endDate = startDate + time.delta(month=12,day=31) -%}
{% set numDays = (endDate - startDate).days -%}
{% for x in range(0, numDays + 1) -%}
{% set dateRec = startDate + time.delta(days=x) -%}
{% if (dateRec.weekday() == 6) -%}
{{ dateRec|date_ymd }}{{ ';' if not loop.last }}
{%- endif -%}
{% endfor -%}

Use in a Regex search step and a loop of the results.



------------------------------
Doug Henning
------------------------------