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 / Extract Month of a Dat...
Power Automate
Answered

Extract Month of a Date Field

(0) ShareShare
ReportReport
Posted on by 59
Hey, guys, what's up?
 
I have a form, which has an answer date as one of its output fields, in the following format: "6/3/20 11:45:17".
 
I'd like to extract only the month of that date. I was doing it the way below but it's definitely not working.
 
222.PNG
 
 
 
 
 
 
 
 
 
The WDL expression that I'm using is: formatDateTime(body('Obter_os_detalhes_da_resposta')?['submitDate'])?['MMMM']
 
Thanks!! 
Categories:
I have the same question (0)
  • efialttes Profile Picture
    14,756 on at

    Hi!

    If the output from your form response is the following, I am afraid formatDateTime() is useless:

    6/3/20 11:45:17

     

    Assuming in this example month is nr 6 you can try with the following expression instead:

    first(split('6/3/20 11:45:17','/'))

     

    But if in your example month is nr 3 instead you can try ith the following WDL expression instead:

    split('6/3/20 11:45:17','/')[1]

     

    You just need to replace '6/3/20 11:45:17' in the expressions and add the corresponding dynamic content instead

    Hope this helps

  • Rebecca7 Profile Picture
    59 on at
    Hello my friend!
     
    That expression worked! (first(split('6/3/20 11:45:17','/')))
     
    But I was thinking better... is it possible to turn this date into "June 2020"?
  • MJain Profile Picture
    2,450 on at

    Hi @Rebecca7 ,

     

    FormatDatetimevalue will return you the month 

     

    I used for current date time value in compose action with three different formats

    formatDateTime(utcNow(),'MM'
    formatDateTime(utcNow(),'MMM')
    formatDateTime(utcNow(),'MMMM')
     
    and following is the output I am getting 
     
    1.JPG
  • Verified answer
    efialttes Profile Picture
    14,756 on at

    Hi again!


    @Rebecca7 wrote:
    Hello my friend!
     
    That expression worked! (first(split('6/3/20 11:45:17','/')))
     
    But I was thinking better... is it possible to turn this date into "June 2020"?

     

    If you need complex transformations, you will probably need to transform your source date format into ISO 8601 format, that is the one internally supported by Power Automate.

     

     

     

     

    yyyy-MM-ddTHH:mm:ss.fffffffZ

     

     

     

     

    In order to get the year as 'yyyy' you can add an 'Initialize variable' action block, type string, lets call it inputYear, and assign as its value the following expression:

     

     

     

     

    concat('20',first(split(last(split('6/3/20 11:45:17','/')),' ')))

     

     

     

     

    In order to get the month as 'MM' you can add an 'Initialize variable' action block, type string, lets call it inputMonth, and assign as its value the following expression :

     

     

     

     

    if(equals(length(first(split('6/3/20 11:45:17','/'))),2),first(split('6/3/20 11:45:17','/')),concat('0',first(split('6/3/20 11:45:17','/'))))

     

     

     

     

    In order to get the day as 'dd' you can add an 'Initialize variable' action block, type string, lets call it inputDay, and assign as its value the following expression:

     

     

     

     

    if(equals(length(split('6/3/20 11:45:17','/')[1]),2),split('6/3/20 11:45:17','/')[1],concat('0',split('6/3/20 11:45:17','/')[1]))

     

     

     

     

     

    In order to get everything into ISO 8601 you can use the following expression

     

     

     

     

    concat(variables('inputYear'),'-',variables('inputMonth'),'-',variables('inputDay'),'T00:00:00.000000Z')
    

     

     

     

     

     

    Now you can use formatDateTime() to transform it into June 2020.

     

     

     

     

    formatDateTime(concat(variables('inputYear'),'-',variables('inputMonth'),'-',variables('inputDay'),'T00:00:00:000000K'),'MMMM yyyy')

     

     

     

     

     

    Hope this helps

  • Rebecca7 Profile Picture
    59 on at

    Hello @efialttes !

     

    I'm following your instruction but the expression bellow is not working:

     

    if(equals(length(split('6/3/20 11:45:17','/')[1]),2),split('6/3/20 11:45:17','/'[1]),concat('0',split('6/3/20 11:45:17','/')[1]))

     

    Thanks!

     

  • efialttes Profile Picture
    14,756 on at

    Oops!

    if(equals(length(split('6/3/20 11:45:17','/')[1]),2),split('6/3/20 11:45:17','/')[1],concat('0',split('6/3/20 11:45:17','/')[1]))
  • Rebecca7 Profile Picture
    59 on at

    It worked!

     

    But now I'm Facing this problem: 

     

    InvalidTemplate. Unable to process template language expressions in action 'Adicionar_linhas_a_um_conjunto_de_dados' inputs at line '1' and column '2866': 'In function 'formatDateTime', the value provided for date time string '2020-06-03T00:00:00:000000K' was not valid. The datetime string must match ISO 8601 format.'.

     

    I can't understand... "2020-06-03T00:00:00:000000K" isn't already in the ISO format?

  • efialttes Profile Picture
    14,756 on at

    Hi!

    Try with this instead

    2020-06-03T00:00:00:000000Z

  • efialttes Profile Picture
    14,756 on at

    Hi!

    Try with this instead

    2020-06-03T00:00:00.000000Z

  • Verified answer
    Rebecca7 Profile Picture
    59 on at

    I tried "2020-06-03T00:00:00" and worked!!

     

    Thank you for your help and your time once again!!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 976

#2
Valantis Profile Picture

Valantis 863

#3
Haque Profile Picture

Haque 547

Last 30 days Overall leaderboard