Fix Notion Formula Cannot Convert Number to Date: Type Coercion Walkthrough
🔍 WiseChecker

Fix Notion Formula Cannot Convert Number to Date: Type Coercion Walkthrough

You see the error “Cannot convert number to date” in a Notion formula property and the expected date value does not appear. This error occurs when a formula returns a number but Notion expects a date data type. Notion formulas are strict about data types and do not automatically convert numbers to dates. This article explains the root cause of the type mismatch and provides a step-by-step method to coerce a number into a valid date value.

In Notion, a date is a distinct data type that includes day, month, year, and optionally time and time zone. A number is a separate data type that holds integer or decimal values. When you try to assign a number to a date property or return a number from a formula that is set to a date format, Notion raises the conversion error. The fix requires you to build a date object from the individual numeric components using the date() function or to adjust the formula logic so that the output is a date, not a number.

This walkthrough covers the technical reason for the error, the correct syntax for creating dates from numbers, and how to handle common scenarios like timestamps and date math. You will also learn how to avoid this error in future formulas.

Key Takeaways: Type Coercion for Notion Date Formulas

  • Use the date() function: Converts a number or string into a date object. Example: date(2024, 3, 15) returns March 15, 2024.
  • Timestamp conversion with fromTimestamp(): Converts a Unix timestamp (number) into a date. Example: fromTimestamp(1700000000) returns the corresponding date.
  • Combine dateAdd with dateSubtract: Perform date math without breaking the date type. Example: dateAdd(now(), 7, 'days') returns a date, not a number.

ADVERTISEMENT

Why a Number Cannot Be Automatically Converted to a Date in Notion

Notion uses a strict type system for formula properties. Each formula property has an output type that is determined by the functions and values used in the formula. When you write a formula that returns a number, the property type becomes “Number.” If you then try to use that property in a context that expects a date, such as in a database view filter or a relation, Notion shows the error “Cannot convert number to date.” The underlying cause is that Notion does not perform automatic type coercion between numbers and dates. A number like 20240315 is not interpreted as a date. You must explicitly convert the number into a date object using the correct formula functions.

The Difference Between Number and Date Data Types

A number in Notion is a mathematical value. It can be an integer or a decimal. A date is a structured object that represents a specific point in time. A date can include year, month, day, hour, minute, second, and time zone. A number alone does not carry any date context. For example, the number 15 could be a day, a month, or a year. Notion cannot guess your intent. You must use the date() function to construct a date from individual year, month, and day numbers, or use fromTimestamp() to convert a Unix timestamp (a number representing seconds since January 1, 1970) into a date.

Common Formula Patterns That Trigger the Error

The error often appears in these scenarios:

  • You write prop("Start Date") + 7 expecting to add 7 days, but this returns a number, not a date.
  • You extract a day number from a date using day(prop("Date")) and then try to use that number in a date formula.
  • You use formatDate(prop("Date"), "YYYYMMDD") which returns a string, and then try to convert that string back to a number, losing the date type.
  • You use a Unix timestamp as a number without wrapping it in fromTimestamp().

Steps to Convert a Number to a Date in a Notion Formula

The fix depends on the source of the number. Use the method that matches your data structure.

Method 1: Build a Date from Year, Month, and Day Numbers

If you have separate number properties for year, month, and day, use the date() function to combine them.

  1. Create a formula property
    In your Notion database, add a new formula property. Name it “Converted Date.”
  2. Enter the date() function
    In the formula editor, type: date(prop("Year"), prop("Month"), prop("Day")). Replace “Year,” “Month,” and “Day” with the exact names of your number properties. This function returns a date object.
  3. Verify the output type
    The formula property will show a date value. If any of the number properties are empty or invalid, the formula will return an empty value. Ensure all three properties contain valid numbers.

Method 2: Convert a Unix Timestamp to a Date

If you have a Unix timestamp (a number like 1700000000), use fromTimestamp().

  1. Create a formula property
    Add a new formula property named “Timestamp Date.”
  2. Enter the fromTimestamp() function
    Type: fromTimestamp(prop("Timestamp")). Replace “Timestamp” with the name of your number property. The function interprets the number as seconds since January 1, 1970 UTC and returns a date.
  3. Adjust time zone if needed
    Notion displays dates in the time zone of your workspace. If your timestamp is in UTC, the displayed date may be off by hours. Use dateAdd() or dateSubtract() to shift the time.

Method 3: Add Days to a Date Without Breaking the Type

Use dateAdd() instead of arithmetic
To add a number of days to an existing date, use dateAdd(prop("Start Date"), prop("Days to Add"), 'days'). This returns a date, not a number. The same applies for hours, minutes, months, and years. Replace ‘days’ with ‘hours’, ‘minutes’, ‘months’, or ‘years’ as needed.

ADVERTISEMENT

If Notion Still Shows the Conversion Error After Applying the Fix

Formula Returns an Empty Value Instead of a Date

If the formula property shows no value, check that all referenced number properties contain valid numeric data. The date() function requires positive integers for year, month, and day. Month must be between 1 and 12, day must be valid for the given month. If a property is empty or contains text, the formula will fail silently.

Date Value Appears as a Number in the Formula Property

If the formula property still displays a number instead of a date, the formula is not returning a date object. Review the formula for any arithmetic operation that converts the date back to a number. For example, date(prop("Year"), prop("Month"), prop("Day")) + 0 will return a number. Remove any trailing arithmetic.

Timestamp Conversion Shows the Wrong Date

If the timestamp is in milliseconds instead of seconds, divide the number by 1000 before using fromTimestamp(). Use: fromTimestamp(prop("Timestamp") / 1000). This converts milliseconds to seconds.

Notion Date Conversion Functions Compared

Function Input Type Output Type
date(year, month, day) Number (year, month, day) Date
fromTimestamp(number) Number (Unix seconds) Date
dateAdd(date, number, unit) Date + Number + String Date
dateSubtract(date, number, unit) Date + Number + String Date
formatDate(date, format) Date + String String
unixTimestamp(date) Date Number

The date() and fromTimestamp() functions are the primary ways to convert a number into a date. dateAdd and dateSubtract perform arithmetic on dates while preserving the date type. formatDate converts a date to a string for display, but the result is not a date. unixTimestamp converts a date back to a number, which can then be used in calculations.

You can now convert numbers to dates in Notion formulas using the date() function for year-month-day inputs or fromTimestamp() for Unix timestamps. Always use dateAdd() or dateSubtract() to add or subtract time from a date to keep the output as a date type. For advanced date manipulation, combine these functions with formatDate() to extract specific components and then rebuild a date object.

ADVERTISEMENT