# How to execute a task only once per day, regardless of how much times the app is opened after the task?

**URL:** <https://community.thunkable.com/t/how-to-execute-a-task-only-once-per-day-regardless-of-how-much-times-the-app-is-opened-after-the-task/758635>\
**Category:** Questions about Thunkable X\
**Created:** [August 21, 2020, 8:38am UTC](https://community.thunkable.com/t/how-to-execute-a-task-only-once-per-day-regardless-of-how-much-times-the-app-is-opened-after-the-task/758635 "2020-08-21T08:38:19Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![kartik14](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/kartik14/32/44782_2.png) [@kartik14](https://community.thunkable.com/u/kartik14)\
**Post date:** [August 21, 2020, 8:38am UTC](https://community.thunkable.com/t/how-to-execute-a-task-only-once-per-day-regardless-of-how-much-times-the-app-is-opened-after-the-task/758635/1 "2020-08-21T08:38:19Z")

</div>

Hi all! 👋

I have a task to do, let’s say, update a stored value, only once a day. So,

- If the user opens the app for the first time for the day, the task must execute.
- If the user opens the app again the same day, the task must not execute, as it’s already done for the day.
- If the user opens the app some other day (tomorrow/later), the task must execute for the day.

So, the app would update the value once per day the app is opened, and I would use the updated value later inside the app for the rest of the day.

Is this possible to do? I have tried with a rough idea, but It seems the blocks I made are wrong 🙁

* * *

I would really appreciate any help/advice 😺  
Thanks! 👍

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [August 21, 2020, 8:43am UTC](https://community.thunkable.com/t/how-to-execute-a-task-only-once-per-day-regardless-of-how-much-times-the-app-is-opened-after-the-task/758635/2 "2020-08-21T08:43:51Z")

</div>

Hi,

The user registers in Fiirebase and after if the date value in the database does not match the current date completing the task and save date in the base.

No, everything is made easier by using the stored variable.

---

<div class="post-metadata">

**Author:** ![kartik14](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/kartik14/32/44782_2.png) [@kartik14](https://community.thunkable.com/u/kartik14)\
**Post date:** [August 21, 2020, 8:48am UTC](https://community.thunkable.com/t/how-to-execute-a-task-only-once-per-day-regardless-of-how-much-times-the-app-is-opened-after-the-task/758635/3 "2020-08-21T08:48:34Z")

</div>

Hi @actech! Thanks a lot for your quick reply! 😺

Your idea seems great, I’ll surely try this out.

* * *

Actually I am using Local Storage for most of my app-tasks, and would see if your idea works with Local Storage too. Also, that _task_ which I am talking about would be updating a localDB data source from Airtable.

So, my final idea is to update the local Data Source only once-a-day on the splash screen, for the rest of the day’s sessions.

Thanks! 😺

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [August 21, 2020, 8:51am UTC](https://community.thunkable.com/t/how-to-execute-a-task-only-once-per-day-regardless-of-how-much-times-the-app-is-opened-after-the-task/758635/4 "2020-08-21T08:51:32Z")

</div>

Launch applications.

If store == null or store != currentDate then {

make tasks and save date in the store

}

---

<div class="post-metadata">

**Author:** ![kartik14](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/kartik14/32/44782_2.png) [@kartik14](https://community.thunkable.com/u/kartik14)\
**Post date:** [August 21, 2020, 8:53am UTC](https://community.thunkable.com/t/how-to-execute-a-task-only-once-per-day-regardless-of-how-much-times-the-app-is-opened-after-the-task/758635/5 "2020-08-21T08:53:05Z")

</div>

Thanks for sharing the workflow! 😺

I am currently trying your idea. 👍

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [August 21, 2020, 11:00am UTC](https://community.thunkable.com/t/how-to-execute-a-task-only-once-per-day-regardless-of-how-much-times-the-app-is-opened-after-the-task/758635/6 "2020-08-21T11:00:05Z")

</div>

I would use the seconds since 1970 block in a stored variable.

If storedTime \> 84600  
Do task  
Else If storedTime \< 86400  
Display alert “too soon”

---

<div class="post-metadata">

**Author:** ![cttricks](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/cttricks/32/93678_2.png) [@cttricks](https://community.thunkable.com/u/cttricks)\
**Post date:** [August 21, 2020, 1:07pm UTC](https://community.thunkable.com/t/how-to-execute-a-task-only-once-per-day-regardless-of-how-much-times-the-app-is-opened-after-the-task/758635/7 "2020-08-21T13:07:24Z")

</div>

I used day month and date to make unique ID of each day… And used this as tag… Aloso added VC { Visit Count } as suffix, And used it asa tag were i count and store the visit/no-of-time-a-user-open-app-after-task. 😅 Hope this will work too…

 ![Screenshot (65)](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/3/1354c246ddd752ffc6e7980eff3d2bf5266f9ddc.png)  
 ![Screenshot (66)](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/a/9a03853f1f0ec2ca9d5b35046baa6eded6e94cf5.png)

Ct tricks

---

<div class="post-metadata">

**Author:** ![kartik14](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/kartik14/32/44782_2.png) [@kartik14](https://community.thunkable.com/u/kartik14)\
**Post date:** [August 21, 2020, 1:08pm UTC](https://community.thunkable.com/t/how-to-execute-a-task-only-once-per-day-regardless-of-how-much-times-the-app-is-opened-after-the-task/758635/8 "2020-08-21T13:08:56Z")

</div>

Thanks @cttricks! Beautiful Idea 👍

btw by _ **date** _, I meant dd/mm/yyyy only 🙂

Thanks again! 😺

---

<div class="post-metadata">

**Author:** ![kartik14](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/kartik14/32/44782_2.png) [@kartik14](https://community.thunkable.com/u/kartik14)\
**Post date:** [August 22, 2020, 3:50am UTC](https://community.thunkable.com/t/how-to-execute-a-task-only-once-per-day-regardless-of-how-much-times-the-app-is-opened-after-the-task/758635/9 "2020-08-22T03:50:42Z")

</div>

**Update :** @actech your solution has worked! 😺

Thanks a lot! 👍

* * *

Also, If I may ask, what if I want to accomplish that task **weekly**?

Thanks! 😺

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [August 22, 2020, 6:28am UTC](https://community.thunkable.com/t/how-to-execute-a-task-only-once-per-day-regardless-of-how-much-times-the-app-is-opened-after-the-task/758635/10 "2020-08-22T06:28:51Z")

</div>

In this case, the easiest way is to use a block with milliseconds.

IF (store == null ) or (store \> getMillisecons + millisecondscountforweek) then {  
store = getMillisecons  
maketask  
}

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 12:24pm UTC](https://community.thunkable.com/t/how-to-execute-a-task-only-once-per-day-regardless-of-how-much-times-the-app-is-opened-after-the-task/758635/11 "2024-11-08T12:24:39Z")

</div>


