How to set date picker with transformer

I'm trying to set up a button that resets the dates to today. However, I can't seem to make daterangepicker.setStartValue() work.

I've tried with the transformer, a Query JSON with SQL and a Run JS Code resource - all with no result.

What's weirder, the docs say I should be able to do this!

I was curious, so I added a daterangepicker , then made a new js query, and it worked immediately for me.
even code completion was working


My query runs successfully, but the value isn't changed. Did it actually change the start value @jnui?

actually no, I don’t believe so.
I set it to add 5 days, moment().add(5, ‘days’)
and it did nothing
setting within the inspector works ok, {{ moment().add(5, ‘days’) }}
but not in the script.

I don't know if this helps, but it does work by utilizing the inspector fields
see screenshot

That’s a bummer - on the one hand I’m glad it’s not me. On the other hand I wish that it was working for you and you had a quick fix for me. #sigh

Well, hopefully somebody at Retool will see this soon. :slight_smile:

Hiya!@mathfour & @jnui try setting the format like this -daterangepicker1.setStartValue(moment().format('YYYY-MM-DD'))
LMK if that works for you!

Nope - I get a successful message, but no change in the actual daterangepicker date.

However, I DO get this interesting alert:

Hi mathfour,

The unexpected token error is coming from a wrong character in the date format input. I think this is an issue with our forum software replacing characters when it is not in a code block. That being said, I tested the script below and it worked.

The correct code snippet is:




More context on this here:

Before, with the invalid characters, you can see that a yellow underline shows an error in the script.

I'll see if we can fix this in our forum software and hope this helps!

1 Like

Thanks @grace! That is so weird - I retyped them and voila! it works.