How should dates be formatted for the Notion API?

I’m having trouble with date formatting in the Notion API. I keep getting this error:

{
  "object": "error",
  "status": 400,
  "code": "validation_error",
  "message": "Invalid date value for Bal."
}

I’ve tried different formats like:

2021/05/14
2021/14/05
2021/5/14
2021/05/14 00:00:00

But none of them work. It’s frustrating that the correct format isn’t clearly stated in the docs. Can anyone tell me the right way to format dates for the Notion API? What am I missing here?

From my experience working with the Notion API, the ISO 8601 format is indeed the way to go. I’ve found that using ‘YYYY-MM-DD’ consistently works for date-only fields, while ‘YYYY-MM-DDTHH:mm:ss.sssZ’ is necessary for datetime fields. The key is to ensure the format is precise and consistent.

One caveat I’ve encountered is that Notion sometimes interprets dates based on the user’s timezone settings. To avoid any discrepancies, I always explicitly specify the timezone, even if it’s UTC.

Another tip: when updating existing date properties, I’ve had success by retrieving the current value first, then modifying only the parts I need to change. This approach has helped me avoid unexpected formatting issues.

Lastly, double-check that your API calls are correctly structured. Sometimes the error you’re seeing can be caused by issues in other parts of the request, not just the date format itself.

ive had similar issues mate. the format that works for me is ‘2021-05-14’ for just dates or ‘2021-05-14T12:00:00Z’ if u need time too. make sure ur using quotes around the date in ur json. also double check ur property names, sometimes i messed up there and got weird errors. good luck!

I feel your pain with the Notion API date formatting - it can be a real headache! After banging my head against the wall for hours, I finally figured out the trick. The format that worked consistently for me is ISO 8601. So try something like ‘2021-05-14T00:00:00Z’ or just ‘2021-05-14’ if you don’t need time.

The ‘T’ separates the date and time, and the ‘Z’ indicates UTC timezone. If you need a specific timezone, you can use an offset like ‘+05:00’ instead of ‘Z’.

Also, make sure your date string is properly escaped if you’re sending it as part of a JSON payload. That tripped me up a few times too.

Hope this helps save you some frustration! Let me know if you run into any other quirks with the API.