cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lcalamita
Frequent Visitor

formatDateTime return the wrong date format

Hi all, 

I'm lost in a very simple date format issue that I can't understand. Maybe you can help me looking at it from outside

I have a basic expression to return the month number from today's date:

 

formatDateTime(utcNow(),'M')

 

now I expected this to return a number between 1 and 12 (of type string, but still a number), but instead is returning "November 29"

 

what am I doing wrong?

thanks for help

 

1 ACCEPTED SOLUTION

Accepted Solutions
mahoneypat
Solution Sage
Solution Sage

You can use this expression instead.  If you want it as just text (01,02, etc.), you can leave off the int( ).

int(formatDateTime(utcNow(), 'MM'))
 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

2 REPLIES 2
mahoneypat
Solution Sage
Solution Sage

You can use this expression instead.  If you want it as just text (01,02, etc.), you can leave off the int( ).

int(formatDateTime(utcNow(), 'MM'))
 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


lcalamita
Frequent Visitor

just to outline, for whomever is having the same issue.
The 'M' notation is reserved for a standard Date Format pre-built by Microsoft, that will return full Month name + Day of month (i.e.: November 29).
therefore, when using a Custom Date Format (like I was trying to achieve) you're not allowed to return month number with a single digit, but you're obliged to use 'MM' notation.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,732)