Power Automate getPastTime() Function (Syntax, Formats and Filter Query Examples)

The Power Automate getPastTime() function returns the current UTC time minus a number of time units, for example getPastTime(7, 'Day') for exactly one week ago. It’s the quickest way to build “in the last 7 days” or “older than one year” conditions without first getting the current time.

I use it mostly in SharePoint filter queries: a weekly flow that emails the orders created in the last 7 days, or a cleanup flow that finds items older than a year. In this tutorial, I’ll cover the syntax, every time unit with real output from a test run on 10/27/2026, date formats, time zones, and the filter query patterns that work.

Quick answer: Syntax: getPastTime(interval, 'timeUnit', 'format'). The interval is a whole number, the unit is Second, Minute, Hour, Day, Week, Month or Year, and the format is optional. getPastTime(7, 'Day') returns a UTC timestamp such as 2026-10-20T06:27:46.7139190Z. Use convertFromUtc() if you need local time.

getPastTime() syntax

getPastTime(<interval>, '<timeUnit>', '<format>'?)
ParameterRequiredDetails
intervalYesA whole number, without quotes: 7, not ‘7’
timeUnitYesSecond, Minute, Hour, Day, Week, Month or Year (singular)
formatNoA .NET date format such as ‘yyyy-MM-dd’ or ‘MM/dd/yyyy’. The default ‘o’ gives ISO 8601: yyyy-MM-ddTHH:mm:ss.fffffffK

The function always starts from now in UTC. You can’t give it another start date. If you need to go back from a date in a column, use subtractFromTime instead, which I compare later. If you only need the current time, see the utcNow function and its formats.

getPastTime() examples for each time unit

To try the function, create an instant flow with Manually trigger a flow, add a Compose action, select fx in Inputs, type the expression and select Add. I put several expressions in one Compose so I could compare them side by side:

Power Automate raw outputs comparing utcNow() 2026-10-27T06:27:46Z with getPastTime(7, 'Day') 2026-10-20 and getPastTime(1, 'Month', 'MM/dd/yyyy') 09/27/2026

The flow ran at 06:27:46 UTC on 10/27/2026. These are the results:

ExpressionOutput
utcNow()2026-10-27T06:27:46.7139031Z
getPastTime(7, ‘Day’)2026-10-20T06:27:46.7139190Z
getPastTime(3, ‘Hour’)2026-10-27T03:27:46.7139266Z
getPastTime(2, ‘Week’, ‘yyyy-MM-dd’)2026-10-13
getPastTime(1, ‘Month’, ‘MM/dd/yyyy’)09/27/2026
getPastTime(-1, ‘Day’)2026-10-28T06:27:46.7139419Z

Notice that the time of day is kept. getPastTime(7, 'Day') isn’t midnight seven days ago, it’s this exact moment seven days ago. If you want the start of a day, add a date-only format, as in the Week example.

The last row shows that a negative interval moves forward in time. It works, but it’s confusing to read. For future dates, use getFutureTime instead.

Months and years respect the calendar: one month before 10/27 is 09/27, not 30 days earlier. For more format patterns, see the formatDateTime function, which uses the same format strings.

Get SharePoint items from the last 30 days

This is the most useful job for getPastTime. My Contoso Customer Orders list has an OrderDate column, and I want only the orders from the last 30 days.

  1. Add the SharePoint Get items action and select your site and list.
  2. Open Advanced parameters and add Filter Query and Order By.
  3. In Filter Query, type OrderDate ge ', insert the expression getPastTime(30, 'Day', 'yyyy-MM-dd') with fx, and close the single quote.
  4. In Order By, enter OrderDate desc to get the newest orders first.
Power Automate Get items action on the Customer Orders list with the Filter Query OrderDate ge getPastTime() and Order By OrderDate desc

When the flow runs, the expression is replaced by the actual date. In the run history, the action’s raw inputs show the filter that SharePoint received:

Power Automate raw inputs of Get orders from the last 30 days showing the evaluated filter OrderDate ge '2026-09-27'

It returned the 7 orders placed since 09/27/2026. The single quotes around the date are required, because OData compares dates as strings in this format. For more patterns, such as today or a date range, see Get items filter queries by date.

For a date-only column, I use the ‘yyyy-MM-dd’ format. For a date and time column such as Created, the default ISO format works and keeps the time:

Created ge '@{getPastTime(7, 'Day')}'

To know how many items matched, wrap the Get items output in length(). I explain that in counting SharePoint list rows.

More ways to use getPastTime()

  • Find old items to archive: in a scheduled flow, filter with Modified lt '@{getPastTime(1, 'Year')}' and move or flag the results.
  • A time window: Created ge '@{getPastTime(1, 'Day')}' and Created le '@{utcNow()}' returns the items from the last 24 hours.
  • Filter an array: in the Filter array action, use @greaterOrEquals(item()?['Created'], getPastTime(30, 'Day')) on data that doesn’t support filter queries.
  • Dynamic intervals: if the number comes from a variable or a text input, convert it: getPastTime(int(variables('Days')), 'Day').

If you call getPastTime in several actions, each call reads the clock again, so the values can differ by a few seconds. When the same cutoff must be used in more than one place, compute it once in a Compose and reuse that output.

Convert the result to your time zone

getPastTime always works in UTC. That’s fine for filters, because SharePoint stores dates in UTC too, but it’s confusing in an email. To show the time in Eastern Time, wrap it with convertFromUtc:

convertFromUtc(getPastTime(1, 'Day'), 'Eastern Standard Time', 'MM/dd/yyyy h:mm tt')

Use the Windows time zone name, such as Pacific Standard Time or Central Standard Time. There are more examples in converting UTC to a local time zone.

Be careful with date-only filters close to midnight. A flow that runs at 11 PM Eastern Time is already on the next day in UTC, so a ‘yyyy-MM-dd’ cutoff can be one day off from what users expect. Convert first if the calendar day matters.

getPastTime vs subtractFromTime vs addDays

ExpressionStarts fromExample
getPastTimeNow (UTC)getPastTime(7, ‘Day’)
subtractFromTimeAny timestampsubtractFromTime(triggerBody()?[‘DueDate’], 7, ‘Day’)
addDaysAny timestamp, days onlyaddDays(utcNow(), -7)

When they start from now, all three return the same moment. Use subtractFromTime when you start from a date in your data, such as a due date. Both are covered in the addToTime and subtractFromTime functions, and the days-only version is in the addDays function.

Common getPastTime errors

  • The template language function expects an integer: the interval is in quotes, such as ‘7’. Remove the quotes or use int().
  • Invalid time unit: the unit is plural or misspelled. Use ‘Day’, not ‘Days’.
  • The filter returns nothing: check the quotes around the date in the Filter Query and that you used the column’s internal name.
  • The date is one day off: the flow compares UTC dates. Convert to your time zone before formatting a date-only value.

These date and time tutorials go well with getPastTime:

Frequently Asked Questions

Does getPastTime return UTC or local time?

It returns UTC, as the examples in the Microsoft expression reference show. Wrap it in convertFromUtc to display local time.

How do I get SharePoint items created in the last 7 days?

Use the Get items Filter Query Created ge ‘@{getPastTime(7, ‘Day’)}’, including the single quotes around the expression.

Can I use a negative number in getPastTime?

Yes, a negative interval returns a future time, but getFutureTime is clearer for that.

How do I return only the date from getPastTime?

Add a format as the third parameter, for example getPastTime(1, ‘Day’, ‘yyyy-MM-dd’) or ‘MM/dd/yyyy’.

What is the difference between getPastTime and subtractFromTime?

getPastTime always starts from the current UTC time. subtractFromTime starts from any timestamp you give it.