Handling Null and Blank Date Fields in Power Automate
In this series: Power Automate gotchas
Checking whether a date field is blank in Power Automate is trickier than a null comparison. The same empty cell arrives as null, "", 0, 1900-01-01, or 0001-01-01T00:00:00Z depending on the connector. A condition that only tests equals(..., null) will pass on Dataverse and fail on SharePoint, then fail again when someone pastes the flow onto an Excel table.
This post is the checklist I use before I trust a date gate in production.
What "empty" actually is
When you pull a date from a connector, an unset value can appear as:
| Source | Typical empty shape | Also seen |
|---|---|---|
| Dataverse | null | 0001-01-01T00:00:00Z on some datetime columns after a failed import |
| SharePoint | "" | Missing property if the column was not in the view |
| SQL Server | null | 1900-01-01 from older schemas and default constraints |
| Excel | "" | Serial 0, which some actions render as 1899-12-30 |
| Forms / HTTP JSON | missing property | null if the sender included the key |
A simple equals(field, null) misses the string and sentinel cases. empty() alone misses a real timestamp that happens to be the sentinel. You need both a "no value" test and a "this is a dummy date" test.
The portable expression
Use empty() around coalesce() so null and "" collapse to the same thing:
@empty(coalesce(triggerOutputs()?['body/dateField'], ''))
If the field is null, coalesce falls back to an empty string, and empty() returns true. If the field is already "", coalesce keeps it and empty() is still true. If the field is a real ISO timestamp, empty() is false.
The ? on the path matters. Without it, a missing property fails the expression and the run errors instead of taking the "blank" branch. That is the same path-safety habit as runtime null handling.
Sentinels: 0001-01-01, 1900-01-01, Excel 0
Some connectors return a date instead of null. Add an explicit check for the dummy values you have actually seen in the trigger output — do not guess a list of every epoch in computing.
@or(
empty(coalesce(triggerOutputs()?['body/dateField'], '')),
equals(formatDateTime(triggerOutputs()?['body/dateField'], 'yyyy-MM-dd'), '0001-01-01'),
equals(formatDateTime(triggerOutputs()?['body/dateField'], 'yyyy-MM-dd'), '1900-01-01'),
equals(formatDateTime(triggerOutputs()?['body/dateField'], 'yyyy-MM-dd'), '1899-12-30')
)
formatDateTime on a true empty string throws. That is why the empty(coalesce(...)) clause comes first, and why this expression belongs in a Condition that short-circuits, or in a Compose that only runs after you know the value is present. If you put formatDateTime on a raw SharePoint empty string, the run fails before the or can save you.
A safer two-step:
- Compose
DateValue—@coalesce(triggerOutputs()?['body/dateField'], '') - Condition —
@or(empty(outputs('DateValue')), contains(string(outputs('DateValue')), '0001-01-01'), contains(string(outputs('DateValue')), '1900-01-01'), contains(string(outputs('DateValue')), '1899-12-30'))
contains on the string form avoids calling formatDateTime on garbage. It is uglier. It does not throw.
Filter at the trigger, not after
If the flow should not run when the date is empty, do not detect it in a Condition action. A Condition still starts a run and still counts against Power Platform request limits. Use the connector's filter or a trigger condition.
Dataverse Filter rows on the trigger:
datefield eq null
That is OData. Use the logical name, not the display name. Choice and lookup columns have different empty tests; dates are eq null.
SharePoint list trigger condition (Settings on the trigger):
@not(empty(triggerOutputs()?['body/DateField']))
SharePoint's body uses the internal column name. If you just renamed the column, the body key is still the old internal name. Take one unfiltered run and read the output.
Skipping the run is cheaper than starting it and terminating. It also keeps run history readable: every row in history is a row that had a date.
Dataverse condition cards
With the current Dataverse connector, a Condition card can compare a date field to null by leaving the value blank and choosing is equal to. That works for Dataverse null. It still fails for SharePoint empty strings, Excel serial 0, and SQL 1900-01-01.
If the flow might be reused across connectors, keep empty(coalesce(...)) plus the sentinel check. If the flow is Dataverse-only and the column is a real datetime with no import garbage, the blank Condition card is enough — and easier for the next person to read.
Excel-specific: serial zero
Excel Online (Business) often gives you a number, not an ISO string, when the cell is a date format. An empty-looking cell can be 0. empty(0) is false because 0 is a value. Test the number before you format it:
@or(empty(coalesce(items('Apply_to_each')?['DueDate'], '')), equals(items('Apply_to_each')?['DueDate'], 0))
If a later action needs a timestamp, only call addDays('1899-12-30', int(serial)) after that check. Converting 0 first and then testing the formatted date works, but you have already invented 1899-12-30 and you will forget why it is in the run.
What I do not do
- I do not compare dates with
equals(..., '')on Dataverse. Dataverse sendsnull. - I do not use
ticks()on a value I have not proven is a date.ticks('')fails the run. - I do not treat "date is in the past" as a blank check. A real 2019 close date is not empty.
- I do not copy the same expression across three connectors without opening one payload from each.
Key takeaway
Never trust a single null check for dates across connectors. empty(coalesce(...)) handles null and "". A second clause handles the dummy timestamps your source actually emits. Prefer Filter rows or a trigger condition when the flow should not start. Read one trigger body before you write the expression — the property name and the empty shape are in that JSON, not in the designer label.
Keep reading
Perform a Changeset Request: Two Add a New Row Actions Are Two Transactions
Only Add, Update, and Delete belong in a Dataverse changeset. List rows is not in that transaction, and the next Add a new row is its own commit.
Add a New Row: The Lookup Is accounts(guid), Not the GUID
Add a new row binds lookups as entityset(guid). A raw GUID or name is not a bind.
Filter Rows: The Lookup GUID Is _parentcustomerid_value
Filter rows is Dataverse OData. Lookups filter on _logicalname_value, not the name. Filter array runs after the download, and @equals does not belong in that box.
Get a Row by ID: Missing Fails the Run, Empty List Rows Does Not
Get a row by ID fails the run when the GUID is missing. List rows with zero matches succeeds. Look up the business key and branch on empty.
When an HTTP Request Is Received: The Callback URL Is a Secret
The HTTP trigger URL carries a SAS signature. Anyone with it can start the flow. Restrict who can call, always Respond, and never treat that URL as public.
Power Automate Do Until: The Loop That Succeeds After Giving Up
A Do until that hits count or timeout still succeeds. Put Get inside the loop, add a Delay, and test the condition after the loop exits.
Newsletter
New posts, straight to your inbox
One email when a new post goes up. Double opt-in, unsubscribe anytime. Not a daily digest.
Comments
- No comments yet. Be the first.