web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / calculate YearIsoweek ...
Power Automate
Answered

calculate YearIsoweek from a date

(0) ShareShare
ReportReport
Posted on by 6

Hi everyone,

I have an excel file with a column with dates and I have to calculate the YEAR and the ISOweek starting from the input date.
the output should be YearIsoweek something like 202416.
The input isa bunch of dates like this:  5/4/2024 12:00:00 AM
Any idea how to do it? Maybe a powershell script? or Python? I don't know any of these programming languages..

Thanks to all.

I have the same question (0)
  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Python has an isocalendar() method in the datetime module that you can use to do this. Use the following script in Run Python script to get it:

     

    import datetime
    year = str(datetime.date(%FormattedDate%).isocalendar()[0])
    week = str(datetime.date(%FormattedDate%).isocalendar()[1])
    
    print(year+week)

     

    Note: %FormattedDate% must be formatted as yyyy, M, d (for example, today would end up as 2023, 9, 13) as that is the format that this method expects. Use Convert date time to text to format it like this.

    Another note: The print command in Python will return the output with a newline at the end. Use Trim text to remove it afterwards.

    Final note: The year can actually also be retrieved without using Python if you will. You could also use Convert date time to text to get the year. But there is no native way to get the week number. So, I would kind of suggest using a single script to get both as the easier alternative, when you need to use scripting anyway.

     

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • mauri_5 Profile Picture
    6 on at

    Thanks a lot!!

    that worked as a charm.

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 481

#2
11manish Profile Picture

11manish 278

#3
David_MA Profile Picture

David_MA 276 Super User 2026 Season 1

Last 30 days Overall leaderboard