Filter posts

  • mr.r5163-1312066443797332018

    Mr.R

    4 months 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.
    1312066444229611592-Skarmavbild_2024-11-29_kl._14.59.25.png
    βœ…1
  • tomthebigtree-1312163491905278024

    Tom Ireland

    4 months 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.r5163-1312445286672629843

    Mr.R

    4 months 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.
  • lucasg-1312450162802561097

    Lucas G

    4 months ago

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

    Tom Ireland

    4 months 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
  • mr.r5163-1312464244608077985

    Mr.R

    4 months 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?
    1312464244343570483-Skarmavbild_2024-11-30_kl._17.59.18.png
  • tomthebigtree-1312472905115762738

    Tom Ireland

    4 months 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.
    1312472905786982541-Screenshot_88.png
    πŸ‘2
    βœ…1
  • 895928090490970153-@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.
    lucasg-1312492438333423676

    Lucas G

    4 months ago

    Now already returns a timestamp.
  • lucasg-1312492462052212747

    Lucas G

    4 months ago

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

    Lucas G

    4 months 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.r5163-1312523704718327848

    Mr.R

    4 months ago

    Oh ok, it's about converting part, got it working thanks!
    πŸ™Œ2
  • tomthebigtree-1312706254233141288

    Tom Ireland

    4 months 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. πŸ‘
    1312706253558120519-Screenshot_89.png
    1312706254069694545-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.