Power Automate Desktop - Date & Time Handling Flow
🔄 Power Automate Desktop - Date & Time Handling Flow
This flow demonstrates how to work with date and time values in Power Automate Desktop. It shows multiple formatting methods for both date and time, using standard formats and custom formats. It also includes converting formatted text back into a DateTime value.
Step-by-Step Explanation
-
Get Current Date and Time
The flow begins by retrieving the current system date and time using the action Get Current Date and Time, and stores it in the variableCurrentDateTime. -
Convert Date to Short Date Format (M/d/yyyy)
The flow convertsCurrentDateTimeinto short date format using a standard formatter.
A message box displays the formatted date to the user. -
Convert Time to Short Time Format (h:mm tt)
The time component of the same DateTime value is formatted into short time format, such as 2:54 PM, and displayed to the user. -
Convert Date to Full Month Format (MMMM dd, yyyy)
Using a custom format, the date is shown like: November 24, 2025. -
Convert Date into Custom Textual Format
A more descriptive custom format is used, e.g.: Today is 24th day of November of Year 2025. -
Convert Time to hh:mm:ss tt Format
This displays time in a detailed format, for example: 09:22:18 PM. -
Convert Time into Human-Readable Sentence
Using custom formatting, the time appears like: It is currently 09 hours 22 minutes and 18 seconds. -
Display Full Date and Time with Day Name
A combined custom format shows full information such as: Monday, 24 November, 2025 | 09:22:18 PM -
Convert Custom Text Back to DateTime Object
The last step converts the formatted text back into a proper DateTime variable, allowing computation, comparison, or reuse.
Full Power Automate Desktop Code
# This flow displays the current date and time in different formats. DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime # Convert to short date format Text.ConvertDateTimeToText.FromDateTime DateTime: CurrentDateTime StandardFormat: Text.WellKnownDateTimeFormat.ShortDate Result=> FormattedDateTime Display.ShowMessageDialog.ShowMessage Title: $'''Result''' Message: $'''Current date in \'short date\" text format: %FormattedDateTime%''' # Convert to short time format Text.ConvertDateTimeToText.FromDateTime DateTime: CurrentDateTime StandardFormat: Text.WellKnownDateTimeFormat.ShortTime Result=> FormattedDateTime Display.ShowMessageDialog.ShowMessage Title: $'''Result''' Message: $'''Current time in \'short time\' text format: %FormattedDateTime%''' # Convert to 'MMMM dd, yyyy' Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''MMMM dd, yyyy''' Result=> FormattedDateTime Display.ShowMessageDialog.ShowMessage Title: $'''Result''' Message: $'''Current date in \'MMMM dd, yyyy\' text format: %FormattedDateTime%''' # Custom date sentence Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''\'Today is\' dd\'th day of\' MMMM \'of Year\' yyyy ''' Result=> FormattedDateTime Display.ShowMessageDialog.ShowMessage Title: $'''Result''' Message: FormattedDateTime # Full time format Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''hh:mm:ss tt''' Result=> FormattedDateTime Display.ShowMessageDialog.ShowMessage Title: $'''Result''' Message: $'''Current time in \'hh:mm:ss tt\' text format: %FormattedDateTime%''' # Human readable time sentence Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''\'It is currently\' hh \'hours\' mm \'minutes\' \'and\' ss \'seconds.\'''' Result=> FormattedDateTime Display.ShowMessageDialog.ShowMessage Title: $'''Result''' Message: FormattedDateTime # Full date and time with day name Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''dddd, dd MMMM, yyyy | hh:mm:ss tt''' Result=> FormattedDateTime Display.ShowMessageDialog.ShowMessage Title: $'''Result''' Message: $'''Today\'s date and time is %FormattedDateTime%''' # Convert text to datetime Text.ConvertTextToDateTime.ToDateTimeCustomFormat Text: FormattedDateTime CustomFormat: $'''dddd, dd MMMM, yyyy | hh:mm:ss tt''' DateTime=> TextAsDateTime Display.ShowMessageDialog.ShowMessage Title: $'''Result''' Message: $'''Today\'s date and time is %TextAsDateTime%'''
Comments
Post a Comment