How to get the date for the Monday of the current week?

75 views
Skip to first unread message

MrGreggles

unread,
Jan 25, 2025, 5:32:17 PM1/25/25
to Tasker
Hi,

I need to get a date for the Monday of the current week.

Example: 
Current date: January 26th
Output: "jan 20" (being the Monday of that week)

How could that be done?

Thank you. New to this. 

Rich D

unread,
Jan 25, 2025, 6:45:45 PM1/25/25
to Tasker Google Groups Post
 This seems to work..  assuming if it is currently Sunday then you want the following Monday.

    Task: monday of week
    
    A1: Parse/Format DateTime [
         Input Type: Now (Current Date And Time)
         Input: %date
         Input Format: M-d-yy
         Get All Details: On
         Output Offset Type: None
         Output Offset: 3 ]
    
    A2: Variable Set [
         Name: %offset
         To: 1 - %dt_day_of_week
         Do Maths: On
         Max Rounding Digits: 3
         Structure Output (JSON, etc): On ]
    
    A3: Variable Set [
         Name: %offset
         To: 1
         Structure Output (JSON, etc): On ]
        If  [ %offset = -6 ]
    
    A4: Parse/Format DateTime [
         Input Type: Now (Current Date And Time)
         Input: %date
         Input Format: M-d-yy
         Output Format: E  MMM  d
         Formatted Variable Names: %monday
         Output Offset Type: Days
         Output Offset: %offset ]
    
    A5: Flash [
         Text: %monday
         Continue Task Immediately: On
         Dismiss On Click: On ]
    
    

MrGreggles

unread,
Jan 25, 2025, 7:47:08 PM1/25/25
to Tasker
Thanks heaps, really. Sry for this newbie question but is there a way to directly import that text script you posted to create Actions within the Task (prior to the existing actions). I asked Gemini but it just explained how to add each Action manually.

Here's a screenie:
photos move task in tasker.jpg

Erik Carlin

unread,
Jan 25, 2025, 8:37:18 PM1/25/25
to tas...@googlegroups.com
His instructions are an exact export of the tasks needed and their configuration.

--
You received this message because you are subscribed to the Google Groups "Tasker" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tasker+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/tasker/f890b24d-25fe-4e2c-990d-1e921a51a683n%40googlegroups.com.

MrGreggles

unread,
Jan 25, 2025, 10:26:41 PM1/25/25
to Tasker
Thank you for the input. Yes, I understand. I was just wondering if there's a way to import that within Tasker. Or does each step need to be entered manually? It just seems unexpected for there to be no way for it to be imported in some way.

Rich D

unread,
Jan 26, 2025, 7:59:28 AM1/26/25
to Tasker Google Groups Post
 I was just wondering if there's a way to import that within Tasker. Or does each step need to be entered manually?


There are a few ways to import / export Tasker data.  Posting the exported description is the one most used for small easy to understand actions.  All the info you need is in the description. Just enter each action 1 by 1 and fill out the necessary fields.


 If there are fields in the action that are not listed in the description then those fields just get left as is. 

With all that said .... As with most things Tasker it can get complicated sometimes. After reviewing my first post I noticed there are some action fields that appear to be filled out that you will not see in basic action when you first open it in the editor.  This occasionally happens when you add and remove data from a action while testing. Deleting a field  will sometimes leave in "extra data" in the exported description for that field. 

So for example in my first post you see

Input: %date
         Input Format: M-d-yy

In the Parse format Date action. You will not see these fields in the action editor until you change the "Input Type".   That data is just leftover from some testing I was doing.  :(

Here is the correct export..

    Task: monday of week
    
    A1: Parse/Format DateTime [
         Input Type: Now (Current Date And Time)
         Get All Details: On
         Output Offset Type: None ]
    
    A2: Variable Set [
         Name: %offset
         To: 1 - %dt_day_of_week
         Do Maths: On
         Max Rounding Digits: 3
         Structure Output (JSON, etc): On ]
    
    A3: Variable Set [
         Name: %offset
         To: 1
         Structure Output (JSON, etc): On ]
        If  [ %offset = -6 ]
    
    A4: Parse/Format DateTime [
         Input Type: Now (Current Date And Time)
         Output Format: E  MMM  d
         Formatted Variable Names: %monday
         Output Offset Type: Days
         Output Offset: %offset ]
    
    A5: Flash [
         Text: %monday
         Continue Task Immediately: On
         Dismiss On Click: On ]
    
    
Sorry for any confusion.... :)

MrGreggles

unread,
Jan 26, 2025, 5:02:17 PM1/26/25
to Tasker
That's such an amazing reply. You're right on that I got stumped by the mismatch of fields. Got it sorted now. 
Reply all
Reply to author
Forward
0 new messages