Use of Date & Time Expressions Guide for Power Automate – Complete Tutorial
Date and Time field manipulations are very common in business applications. In Power Automate we can use a list of Data & Time related expressions to manage data time fields. In this post we will discuss all expressions about data and time field expressions.
The below is the list of data & time expressions available in Power Automate. The Date Time fields expressions use format as common parameter to understand all formats of date time refer here Standard Formats & Custom Formats.
The below examples are constructed by taking a variable “Initial Date“.
The date taken as source date is “2021-09-13T00:00:00Z” (year-month-dayThh:mm:ssZ)
Expressions | Description |
---|---|
addDays | This function is used to add number of days to an existing timestamp. You can also use negative number to deduct days. Syntax : addDays('<timestamp>', <days>, '<format>'?) Ex : addDays(variables(‘Initial Date’),7,’f’) Ex : addDays(variables(‘Initial Date’),-7,’f’) |
addHours | This function is used to add number of hours to an existing timestamp. You can also use negative number to deduct hours. Syntax : addHours('<timestamp>', <hours>, '<format>'?) Ex : addHours(variables(‘Initial Date’),5,’f’) Ex : addHours(variables(‘Initial Date’),-5,’f’) |
addMinutes | This function is used to add number of minutes to an existing timestamp. You can also use negative number to deduct minutes. Syntax : addMinutes('<timestamp>', <minutes>, '<format>'?) Ex : addMinutes(variables(‘Initial Date’),5,’f’) Ex : addMinutes(variables(‘Initial Date’),-5,’f’) |
addSeconds | This function is used to add number of seconds to an existing timestamp. You can also use negative number to deduct seconds. Syntax: addSeconds('<timestamp>', <seconds>, '<format>'?) Ex : addSeconds(variables(‘Initial Date’),6,’f’) Ex : addSeconds (variables(‘Initial Date’),-6,’f’) |
addToTime | This function adds a number of time units to an existing timestamp. You can also use negative number to deduct timestamp. Syntax : addToTime('<timestamp>', <interval>, '<timeUnit>', '<format>'?) Ex: addToTime(variables(‘Initial Date’) , 1, ‘Day’) Ex: addToTime(variables(‘Initial Date’) , -1, ‘Day’) You can use time unit as : “Second”, “Minute”, “Hour”, “Day”, “Week”, “Month”, “Year” |
convertFromUtc | This function converts an existing timestamp from Universal Time Coordinated (UTC) to the target time zone. For all Time zone codes see here. Syntax: convertFromUtc('<timestamp>', '<destinationTimeZone>', '<format>'?) For example if you want to convert UTC to EST then you have to use like below. Ex : convertFromUtc(variables(‘Initial Date’) , ‘Eastern Standard Time’,’f’) |
convertTimeZone | This function converts a timestamp from the source time zone to the target time zone. Syntax : convertTimeZone('<timestamp>', '<sourceTimeZone>', '<destinationTimeZone>', '<format>'?) Example : If you want to convert from India Standard Time (IST) to Eastern Standard Time (EST) then use the expression as below: Ex: |
convertToUtc | This function converts an existing timestamp to Universal Time Coordinated (UTC). For all Time zone codes see here. Syntax: convertToUtc('<timestamp>', '<sourceTimeZone>', '<format>'?) For example if you want to convert IST to UTC then you have to use like below. Ex : convertToUtc(variables(‘Initial Date’) , ‘Indian Standard Time’,’f’) |
dayOfMonth | This expression return the day of the month from an existing timestamp. Syntax: dayOfMonth('<timestamp>') Example : This example returns the number for the day of the month from this timestamp: dayOfMonth( variables(‘Initial Date’)) It returns this result: 13 |
dayOfWeek | This expression return the day of the week from an existing timestamp. Syntax: dayOfWeek('<timestamp>') Example : This example returns the number for the day of the week from this timestamp: dayOfWeek(variables(‘Initial Date’)) It returns this result: 1 NOTE : The day of the week from the specified timestamp where Sunday is 0, Monday is 1, and so on |
dayOfYear | This expression return the day of the year from an existing timestamp. Syntax: dayOfYear('<timestamp>') Example : This example returns the number for the day of the year from this timestamp: dayOfYear(variables(‘Initial Date’)) It returns this result: 256 |
formatDateTime | This expression returns the date format from a timestamp. Example to display in “yyyy-MM-dd” format then you have to pass like below: formatDateTime(variables(‘Initial Date’),’ yyyy-MM-dd ‘) |
getFutureTime | This Return the current timestamp plus the specified time units. getFutureTime(<interval>, <timeUnit>, <format>?) getFutureTime(5, 'Day', 'D') This returns the timestamp by adding 5 days to the current date. |
getPastTime | This Return the current timestamp minus the specified time units. getPastTime(<interval>, <timeUnit>, <format>?) getPastTime(6, 'Day', 'D') This returns the timestamp by substracting 6 days to the current date. |
startOfDay | Return the start of the day for a timestamp.startOfDay('<timestamp>', '<format>'?) startOfDay('2018-03-15T13:30:30Z') this returns “2018-03-15T00:00:00.0000000Z” |
startOfHour | Return the start of the hour for a timestamp.startOfHour('<timestamp>', '<format>'?) startOfHour('2018-03-15T13:30:30Z') And returns this result:Â "2018-03-15T13:00:00.0000000Z" |
startOfMonth | Return the start of the month for a timestamp.startOfMonth('<timestamp>', '<format>'?) startOfMonth('2018-03-15T13:30:30Z') This example returns the start of the month in the specified format for this timestamp: |
subtractFromTime | Subtract a number of time units from a timestamp.subtractFromTime('<timestamp>', <interval>, '<timeUnit>', '<format>'?) subtractFromTime('2018-01-02T00:00:00Z', 1, 'Day') The unit of time to use with interval: “Second”, “Minute”, “Hour”, “Day”, “Week”, “Month”, “Year” |
ticks | Return the ticks  property value for a specified timestamp.ticks('<timestamp>') ticks(variables(‘Initial Date’)) |
utcNow | Return the current timestamp as a string. |
Hope this helps
Don’t miss the chance to participate in the upcoming Internship Program which will be done using Microsoft Dot Net Web Development Full Stack Technology. The new batch will be starting from May 20, 2024. We will have most experienced trainers for you to successfully complete the internship with live project experience.
Why to choose Our Internship Program?
Industry-Relevant Projects
Tailored Assignments: We offer projects that align with your academic background and career aspirations.
Real-World Challenges: Tackle industry-specific problems and contribute to meaningful projects that make a difference.
Professional Mentorship
Guidance from Experts: Benefit from one-on-one mentorship from seasoned professionals in your field.
Career Development Workshops: Participate in workshops that focus on resume building, interview skills, and career planning.
Networking Opportunities
Connect with Industry Leaders: Build relationships with professionals and expand your professional network.
Peer Interaction: Collaborate with fellow interns and exchange ideas, fostering a supportive and collaborative environment.
Skill Enhancement
Hands-On Experience: Gain practical skills and learn new technologies through project-based learning.
Soft Skills Development: Enhance communication, teamwork, and problem-solving skills essential for career success.
Free Demo Class Available