Function to quickly convert timeSteps back to actual Date values

Hi guys,

when working with linked models I find it quite useful to have only the relevant time frames for each model set up. Otherwise things just get overly cluttered.

This triggers the warning
Bildschirmfoto 2021-11-08 um 14.58.31
quite frequently.

For the most part, it “only” causes missing values which can be overcome easily by following your guidance on setting 0 if variable = none

However, one issue that may be less obvious comes up when you’re using start dates stored in a variable of a linked model with a deviating time frame and compare them to the current timeStep in the local model, like

if myLinkedStartDate <= timeStep then 1 else 0

Since timeSteps and ultimately also Dates stored in Variables are just the IDs of the timesteps, you end up comparing apples with oranges easily.

What could help here would be a function to quickly convert a timeStep or stored date value back to an actual date, or essentially to realign timeStep IDs / stored date value IDs to the current model.

You already have the year_from_date and month_from_date functions, which lead to the assumption that you can actually use these in order to reconstruct a working comparison such as

date(year_from_date(myLinkedStartDate), month_from_date(myLinkedStartDate), 1) 
date(year_from_date(timeStep), month_from_date(timeStep), 1) 
then 1 else 0

Unfortunately this currently still interprets the pure ID in myLinkedStartDate back to a date in the time frame reference model of the local model, rather than returning the actual month (as the function name suggests) … so that new function would have to be able to use the time frame reference model of the source model to return its date values.

Thanks & Regards

Hey Fabian! We are currently doing some product thinking on how Causal handles time - including dates/days within a month. The way we’re envisaging it you should never run into the issue of comparing apples with oranges, and dates should be a lot less clunky to handle.

Let us come back to you on this :nerd_face:

1 Like