How to Initialize a Date Variable in Power Automate [With Examples]

In this Power Automate tutorial, I will show you how to initialize a date variable in Power Automate. Then, I will explain how to initialize a Date variable in Power Automate with Today’s Date.

I will also describe how to initialize a Date variable in Power Automate and add days to the current date.

After that, I will show you how to initialize a Date variable in Power Automate date format (Weekday, Month Day, and Year).

I will demonstrate Power Automate how to initialize a date type variable from a SharePoint Online list.

Initialize A Date Variable in Power Automate

Variables are used to store the values and manage data during the flow in Power Automate. Initializing the variable declares the datatype and initial value of the variable.

Initializing a date variable means it will store the date values and can be used to work with date related information during the flow.

Example: Suppose I have initialized the date variable as today’s date in a Power Automate flow, then the variable holds that date value and can be used throughout the flow.

PropertyDescription
NameEnter a Name for a variable (Todays Date)
TypeSet the datatype to the variable from available datatypes like String, Integer, Float, Boolean, Array, Object.
ValueThis is the optional value.
Power Automate Initialize a Date Type variable

Initialize a Date Type Variable to Get Current Date in Power Automate

Here, I have created a Power Automate flow that will trigger manually to Initialize a date variable to display Today’s date.

Suppose I give the expression for Today’s date in the value column of an initialized variable; then it displays output as the current date value with (Time in the UTC zone).

To achieve this, follow the below instructions:

  • Create a Power Automate Instant cloud flow.
  • Then, Click on + New step under Manually trigger a flow and add Initialize variable action.
How to Initialize a variable with Todays Date in Power Automate
  • Enter the properties of the Initialize variable as mentioned below:
    • Name: It is a mandatory required field.
    • Type: Select the datatype as a string.
    • Value: Provide the mentioned expression.
Expression: formatDateTime(utcNow(),'dd-MM-yyyyTHH:mm:ssZ')
Power Automate Initialize a variable with Todays Date
  • Add Send an email(V2) action under the Initialize variable and provide To, Subject, and Body in the Email.
    • To: Provide user email.
    • Subject: Enter the subject of the email.
    • Body: Provide the output of the initialized variable.
Power Automate Initialize a Date variable with Todays Date
  • After that, Click on Save and select Test.
How to Initialize a Date variable using Power Automate
  • In the Test Flow window, Select Manually, and Click on Save &Test.
Initialize a variable with Todays date using Power Automate
  • Then, the flow will run successfully and send an email to the user as shown below:
Initialize a Date variable with Todays date by Power Automate
Initialize a variable with Todays date by Power Automate

This is how to initialize a date variable with Today’s date using Power Automate flow.

Check an article on Get Current Date in Power Automate.

Power Automate Initialize a Date Variable Add Days to Todays Date

I have explained how to initialize a Date variable by adding days to Today’s date through Power Automate.

This example repeats the same steps mentioned earlier but only adds days to today’s Date.

Example: Suppose Today’s date is 14/09/2023; then I will add +7 days to the current date. So that, it will give the output as 21/09/2023 with Hours: minutes format.

  • In the Power Automate flow, insert wherever you want to insert the initialized variable.
  • In the Initialize variable, enter the properties as mentioned below:
    • Name: It is a mandatory required field.
    • Type: Select the datatype as a string.
    • Value: Give below mentioned expression.
Expression: formatDateTime(addDays(utcNow(),7),'dd-MM-yyyy HH:mm')
How to Initialize Date type variable in Power Automate
  • Next, add the “Send an email (V2)” action and provide the following:
    • To: Provide user email
    • Subject: Give subject to the email
    • Body: Give the output of initialized variable from dynamic content.
Initialize a Date variable expression in Power Automate
  • Once the flow has been created, Save and Test the flow Manually.
  • When the flow runs successfully and sends an email notification to the user that displays adding 7 days to the current date.
Initialize a Date variable expression by Power Automate

This is how to initialize a date variable by adding days to Today’s date using Power Automate flow.

Power Automate Initialize a Date Type Variable (Day of Week, Month Day, and Year)

Now, I will show you how to initialize a date variable in formatdatetime like Day of week, Month Day, and Year.

Example: I was initializing Todays Date i.e.,14/09/2023, then the output will be in the format of Thursday, September 14,2023.

  • Create a Power Automate Instant cloud flow and add an “initialize variable” flow action.
  • In the “initialize variable” flow action, provide the below properties:
    • Name: It is a mandatory field. Set the name as the Todays date.
    • Type: Select datatype as string.
    • Value: Give the below expression.
Expression : formatDateTime(utcNow(),'dddd,MMMM,dd,yyyy')
Get Todays Date and Format Date using Power Automate
  • Add send an email (V2) action and provide below details:
    • To: Provide user email.
    • Subject: Enter the subject for the email.
    • Body: Give the output of the initialized variable from dynamic content.
Get Todays Date and Format Date by Power Automate
  • Once the flow has been created, Click on Save and Test Manually.
  • When the flow runs successfully, the user will receive an email notification displaying Today’s date in weekday, month day, and year format.
Initialize a date variable & Format Date using Power Automate

This is how to initialize a variable with Today’s date, displaying date in the format of Day of week, Month Day, and Year.

Power Automate Initialize a Date Type Variable from a SharePoint List

Now, I will show you how to initialize a date type variable from a SharePoint Online list using Power Automate flow.

For this, I have created a SharePoint Online list named ‘Travel Request‘ with different data types as shown below:

Column NameData Type
Trip TitleTitle column – Renamed it to Trip Title
Travel Start DateDate and Time
Travelling CountryLook Up
Days – Time LimitNumber column
Power Automate Initialize Date Variable

Example: Whenever a user creates an item in the SharePoint list with a Travel Start Date, then it will check the maximum Days- Time limit and send an email notification of the Available Travelling Slot Date to the user.

  • Create an Automated cloud flow with a trigger “When an item is created“, provide below details:
    • Site Address: Select the SharePoint site address from the drop-down menu.
    • List Name: Select the list name from the drop-down.
Power Automate Initialize Date Variable from SharePoint list
  • Next, Add Get item action and enter the below details:
    • Site address: Select the SharePoint site address from the drop-down.
    • List name: Give the list name from the drop-down.
    • Id: Select ID from dynamic content.
Initialize Date Variable from a SharePoint list using Power Automate
  • After that, add an “Initialize variable” flow action, and then set the below-mentioned details:
    • Name: Set a Name for the Variable
    • Type: Select datatype from the drop-down.
    • Value: Give the below expression.
int(outputs('Get_item')?['body/Days_x002d_TimeLimit'])
Initialize Date Variable from a SharePoint list by Power Automate
  • Then, add a compose data operation to bind Travel Start Date [Date column] and output of initialize variable.
Expression : addDays(outputs('Get_item')?['body/TravelStartDate'],variables('Maximum Days Limit'),'dd-MM-yyyy')
Initialize a date variable from SharePoint list using Power Automate
  • Next, add Send an email (V2) action and Provide To, Subject, and Body as shown below:
    • To: Provide created by email.
    • Subject: Enter subject for an email.
    • Body: Give the output of compose action.
Power Automate Initialize a date variable from SharePoint Online list
  • Once the flow has been created, Click on Save and Test the flow manually.
Power Automate Initializing a Date Variable
  • Now, add an item to the SharePoint list; when the flow runs successfully, it will send an email notification to the user as shown below:
Initializing a Date Variable using Power Automate

This is how to initialize a date variable from the SharePoint Online list using Power Automate flow.

Conclusion

Through this Power Automate tutorial, I have explained how to initialize a date variable by using Power Automate flow. Also, I have discussed the below examples on Power Automate Initialize a date variable.

  • How to Initialize a Date Type Variable to Get Current Date
  • Power Automate Initialize a Date Variable Add Days to Todays Date
  • Power Automate Initialize a Date Type Variable (Day of Week, Month Day and Year)
  • Power Automate Initialize a Date Type Variable from a SharePoint List

You may also like: