Dynamic Date Expressions with variables - how is the format in datasources?

Hey there, i need some help with date expressions using variables on a REST Query datasources like facebook, i'm not sure if variables are compatible with date expressions, hope someone can help me.

I have the following REST      https://graph.facebook.com/v2.10/<FACEBOOK_ID>/insights/page_fans_by_like_source/day?since=1522476000&until=1525064400

and i want to replace my dates since and until values   for   since=startofmonth($variable,2 months ago)   and until = endofmonth($variable)  ,  wich in klipfolio must be like this

DATE_STARTOF($MyDate,"3",-2)     wich in klipfolio gets   the start of month 2 months ago   like if i have  17 April  -  i'll receive  1 February in unixtime


the "3"  means month as the period selected in klipfolio


Does anyone know how would be with date expressions?  i made some trys like this but always get error


if i just use props.MyDate like  since={props.MyDate}&until={props.MyDate}   it works ok giving me the 1 day default value, but i need this with more range

Based on those pages:




  • 0
    Oscar Rocha

    I asked to Klipfolio support and it seems that this is not possible

    Date expressions are not compatible with variables in data sources... yet  

    The calculation should be with hidden inputs updated by button having more than 1 variable per calculation.

  • 1
    Janice Janczyn

    Hi Oscar, 

    If I understand your question correctly, you have been able to use variables in the date parameters in your datasource queries (this is supported as you noted), however the issue is with the set method. The set method requires dates to be in the format yyyy-MM-dd, so your MyDate variable must be yyyy-MM-dd format. For example

       {date.set(2010-12-15).format('dd-MMM-yyyy')} returns 15-Dec-2010

    Hope this helps!


  • 2
    Oscar Rocha

    Oh, you are right Janice, date expressions are compatible with variables in data source. It works good adding the .format at the end, that solve it and gonna save tons of variables.

    The final structure for reference must be like this example


    where MyDate = 2018-04-24

    so the result of this is 2018-03-31

    thanks a lot  :)

Please sign in to leave a comment.