Update variable past midnight daily

Options
Hi all - I'm hoping to update a variable right past midnight to a default value daily. I looked into timestamp data manipulation but wasn't able to find a solution. Appreciate any pointers! Cheers.

Comments

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options
    Can you give an example of an input value, and what output value you are looking for in that situation? Like, is it just you want to update field X on table Y to a value of 0 each day? Or is there something more involved? 

    The timing part is straightforward - Xano has a scheduled "background task" feature that you can set the time of day for it to run whatever set of functions. So the question is _what_ you want to have happen in that "stack"
  • Coco Wang
    Coco Wang Member
    Options
     Thanks for the info! 
    Yes, I'm trying to update a field on table Y to a value of 10 each day. Can background task update the value past midnight based on the user's timezone? Or is this something I should implement in the frontend?
  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options
    I could imagine a background task that runs every half hour and checks for users whose time zone offset and date makes the current time “midnight”. (Half hour because some time zones like IST are not on the hour from Greenwich mean time). For those people, reset the value. As long as you have the time zone in a user table that could work!
  • mladen92
    mladen92 Member
    Options

    Hey guys, I have the same problem with the fact that I need to reset some values in the database once a day.

    If I set the condition now(format: userTimezone) === now(format: midnight) this condition will succeed only if 00:00:00 === 00:00:00, but what if the function I am executing is more complex?
    My function might hit this check at 00:01:00.
    I hope you understand the question.

    This bellow is an idea like if in 5 minutes (this is enough for the function to execute) then…do needed resets.
    I'm super tired after some superfluous logic so any idea is more than welcome. ❤️