Is there a way to get the current week?

Hi there,

I am trying to display some data coming from an API response, the data needs to be filtered by the current week so that I can return data only for the ongoing week, so far I know there is the moment() function and there are some other methods like moment().startOf('week').toDate(); which is a type object,

The issue I'm facing is that the value returned from the API response is a string type, so if I compare it to the object returned using the moment()function, it returns a false value all the time

I want to know if there is an easier way in retool on how to do this? My data from the API response has a lot of values in JSON, and one of the properties is 'last_modified' so what I need is to make it show only the values for the current week without me having to use a dropdown or an other interaction, is this possible somehow?

I am using a select dropdown to get date ranges for data....
Someone posted in the forum a while back, the following
Timeframe.json (8.7 KB)

Import that into your Retool instance as another app and you will see... I changed it a bit for my needs and you can do the same...

For a Date Range component, I use
[{{moment().startOf('week').format()}},{{ moment().endOf('week').format()}}]

Screen Shot 2022-06-08 at 8.06.45 AM

1 Like

Hey @RodrigoE! Just want to point out the fact from @ScottR's reply that you can use the .format() function to convert your moment into a string for comparison. Or have moment parse the strings from your API!