PricingDocsAcademy
Bluesky ...
Wed, Dec 11, 10:58 PM

Filter posts

  • /attachments/1312066443797332018/1312066444229611592/Skarmavbild_2024-11-29_kl._14.59.25.png

    Mr.R

    12 days ago

    Still learning Toddle formulas by asking Ai but i can't seem to grasp the function output it describes.
    I'm trying to filter the api response data so that it displays posts/repeated items from within 30 days from publishing dates.

    Attaching a screenshot from my attempt that failed.
    Skarmavbild_2024-11-29_kl._14.59.25.png
    βœ…1
  • Tom Ireland

    12 days ago

    You'll likely need to convert the date to a timestamp and then minus the number of days in seconds. For example, 60 (1 min) * 60 (1 hr) * 24 (1d) = 86400. Times that by 30 = 2592000. Take that from now and that'll give you your 30 days. You'll need to times by 1000 as the timestamp is down to the millisecond.

    Another solution may be to do the filtering on the backend and get the results you need in your API result.
  • Mr.R

    11 days ago

    Hi tom, the first method was suggested by Ai but the problem is when building the formula visually that i'm having problem with to follow and understand when to apply each node. Trying to learn fomula logic based on Ai function output.

    Regarding the second solution, the backend is a public job listing api which unfortunately i don’t have the filtering option.
  • Lucas G

    11 days ago

    If you mean posts created less than 30 days ago then it would be now - 30 days less than publish/created date
    πŸ‘1
  • Tom Ireland

    11 days ago

    Yeah. ☝️ Your minus needs to be between 'Now' and 'Greater than' in the formula. Basically, in 'Greater than', the top value (publication date) has to be greater than the bottom value (now minus 30 days). For those that evaluate to true, they will be the ones remaining.

    At the moment, you're saying the publication date has to be greater than now, which will always be false because now is current time and all those dates will be in the past.
    πŸ‘1
  • /attachments/1312066443797332018/1312464244343570483/Skarmavbild_2024-11-30_kl._17.59.18.png

    Mr.R

    11 days ago

    Thank you guys, it seems to return the filtered items but i still see published date from Sep-Okt which suppose to be hidden if i'm not mistaken?
    Skarmavbild_2024-11-30_kl._17.59.18.png
  • /attachments/1312066443797332018/1312472905786982541/Screenshot_88.png

    Tom Ireland

    11 days ago

    @Mr.R - Okay, the formula is still not quite right.

    For the publication date, instead of 'Date from string', use 'Timestamp'. This will convert the date to a Unix timestamp (see https://en.wikipedia.org/wiki/Unix_time for bedtime reading).

    For the 'now', you need to convert that to a timestamp and then minus 86400000 multiplied by 30 (the number of milliseconds in 30 days).

    See the attached as an example. I added date from timestamp at the end to show you the output so you can see it works but you won't need that for your formula.
    Screenshot_88.png
    πŸ‘2
    βœ…1
  • @Tom Ireland
    @Mr.R - Okay, the formula is still not quite right.

    For the publication date, instead of 'Date from string', use 'Timestamp'. This will convert the date to a Unix timestamp (see
    https://en.wikipedia.org/wiki/Unix_time for bedtime reading).

    For the 'now', you need to convert that to a timestamp and then minus 86400000 multiplied by 30 (the number of milliseconds in 30 days).

    See the attached as an example. I added date from timestamp at the end to show you the output so you can see it works but you won't need that for your formula.

    Lucas G

    11 days ago

    Now already returns a timestamp.
  • /attachments/1312066443797332018/1312492461750485043/image.png

    Lucas G

    11 days ago

    image.png
    βœ…1
    πŸ”₯1
  • That's the formula
  • You subtract 2592000000 (30 days) from now
  • Lucas G

    11 days ago

    And you feed the published date into the date from string unless it is already returning a date object, in which case just convert that to timestamp
  • Mr.R

    11 days ago

    Oh ok, it's about converting part, got it working thanks!
    πŸ™Œ2
  • /attachments/1312066443797332018/1312706253558120519/Screenshot_89.png

    Tom Ireland

    10 days ago

    Every day's a school day! The output from Now always made me think you need to convert it, but I see that as soon as you add something like minus, you get the timestamp as output. Thanks, Lucas. πŸ‘
    Screenshot_89.png
    Screenshot_90.png
    πŸ‘2

Stop scrolling. Start building.

toddle is a visual web app builder that rivals custom code β€” but accessible to your entire team!

Try toddle β€” it's free!

Β© Copyright 2024 toddle. All rights reserved.