Skip to main content
Best answer

Does this date format feature exist

  • December 1, 2022
  • 9 replies
  • 207 views

Forum|alt.badge.img

Hey, I would like to know if this feature exists.

 

Is there any date formatting feature that shows if an input date is first week of the month or second week of the month or third week of the month or 4th week of the.

 

For example, if the input data is November 2nd 2022, then I would like Zapier to tell me that this is the 1st week of the month.

 

Does something like this exist?

Best answer by GetUWiredBest answer by GetUWired

As @Troy Tessalone mentioned, this really will depend on how you want to determine what week you are in.. If you just assume that the 1st of every month is the 1st of the week for that month then the math is fairly straightforward. You would just round up the day of the month divided by 7

i.e November 2: 2/7 = .286 so rounded up is week 1. 
November 15th: 15/7 = 2.143 so rounded up is week 3

with this method you will end up with up to 5 weeks for most months. 

View original
Did this topic help you find an answer to your question?
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

9 replies

Troy Tessalone
Forum|alt.badge.img+14

Hi @Fahad.S 

Good question.

No, that does not exist, and that logic would likely have to be configured in a custom Code step: https://zapier.com/apps/code/help

Also, it depends on how you consider weeks to be calculated. (e.g. starting on Monday, starting on Sunday, starting on some other day, the first week that has 4+ days in the month, etc.)

 

For example, if the input data is November 2nd 2022, then I would like Zapier to tell me that this is the second week of the month.

How would November 2, 2022 be in the second week of the month?


Forum|alt.badge.img
  • Author
  • Beginner
  • 14 replies
  • December 1, 2022
Troy Tessalone wrote:

Also, it depends on how you consider weeks to be calculated. (e.g. starting on Monday, starting on Sunday, starting on some other day, the first week that has 4+ days in the month, etc.)

I would like the week to start with Monday, how would the code look like for this.

How would November 2, 2022 be in the second week of the month?

Ah, my bad lol, I meant to write 1st week of the month

 


Troy Tessalone
Forum|alt.badge.img+14

@Fahad.S 

I have not yet written that type of custom Code.

Perhaps try some GSearches or consider hiring a Zapier Expert: https://zapier.com/experts


Forum|alt.badge.img
  • Author
  • Beginner
  • 14 replies
  • December 1, 2022
Troy Tessalone wrote:

@Fahad.S

I have not yet written that type of custom Code.

Perhaps try some GSearches or consider hiring a Zapier Expert: https://zapier.com/experts

Thanks for letting me know, I found a code on stack overflow but not sure how to implement into Zapier, what do you think.

code I found

def week_of_month(dt):
    """ Returns the week of the month for the specified date.
    """

    first_day = dt.replace(day=1)

    dom = dt.day
    adjusted_dom = dom + first_day.weekday()

    return int(ceil(adjusted_dom/7.0))

 

 


GetUWired
Forum|alt.badge.img+12
  • Zapier Expert
  • 1030 replies
  • Answer
  • December 1, 2022

As @Troy Tessalone mentioned, this really will depend on how you want to determine what week you are in.. If you just assume that the 1st of every month is the 1st of the week for that month then the math is fairly straightforward. You would just round up the day of the month divided by 7

i.e November 2: 2/7 = .286 so rounded up is week 1. 
November 15th: 15/7 = 2.143 so rounded up is week 3

with this method you will end up with up to 5 weeks for most months. 


Forum|alt.badge.img
  • Author
  • Beginner
  • 14 replies
  • December 2, 2022
GetUWired wrote:

If you just assume that the 1st of every month is the 1st of the week for that month then the math is fairly straightforward. You would just round up the day of the month divided by 7

Suppose I assume 1st of every month is the first week of the month, what should I do what should I do to make this happen in Zapier


GetUWired
Forum|alt.badge.img+12
  • Zapier Expert
  • 1030 replies
  • December 5, 2022

You can do this with a code step or 2 formatter steps. 

Formatter Steps:

1st a date time formatter step to return the date. Inputs shown below are a sample your date input might be different than just the current time the zap is running and you might also not be in eastern time. This will give you back just the day portion of the month. 


The second step would be a numbers formatter

 


Forum|alt.badge.img
  • Author
  • Beginner
  • 14 replies
  • December 5, 2022
GetUWired wrote:

You can do this with a code step or 2 formatter steps. 

Formatter Steps:

1st a date time formatter step to return the date. Inputs shown below are a sample your date input might be different than just the current time the zap is running and you might also not be in eastern time. This will give you back just the day portion of the month. 


The second step would be a numbers formatter

 

thanks, will try it out


jesse
Forum|alt.badge.img+9
  • Architect
  • 1348 replies
  • December 7, 2022

@Fahad.S How are things going here? Were you able to configure those Formatter steps and get the result you’re looking for? Let us know - we want to make sure you’re good to go here!