How to include dates when adding events to Notion Calendar?

Hey everyone! I’m struggling with my Notion Calendar. I can add new items, but I can’t figure out how to include dates. Here’s the code I’m using:

async function createEvent(eventName) {
  try {
    const result = await notion.pages.create({
      parent: { database_id: calendarId },
      properties: {
        Name: {
          type: 'title',
          title: [
            {
              type: 'text',
              text: {
                content: 'Team Meeting',
              },
            },
          ],
        },
      }
    })
    console.log('Event added successfully!')
    console.log(result)
  } catch (err) {
    console.log('Oops! Something went wrong:')
    console.error(err.body)
  }
}

createEvent('Weekly Planning Session')

This code adds the event name, but I’m lost on how to add the date. Can anyone help me out? Thanks in advance!

I’ve been using Notion Calendar for a while now, and I can share what worked for me. To include dates when adding events, you need to modify the properties object in your code. Here’s what I did:

Add a ‘Date’ property to your properties object, and set its type to ‘date’. Then, specify the start and end dates for your event. For example:

Date: {
type: ‘date’,
date: {
start: ‘2023-05-15’,
end: ‘2023-05-15’
}
}

Insert this into your properties object, alongside the ‘Name’ property. This should allow you to add both the event name and date to your Notion Calendar.

Remember to format your dates correctly as ‘YYYY-MM-DD’. If you’re dealing with specific times, you can include those too in the format ‘YYYY-MM-DDTHH:mm:ss.sssZ’.

Hope this helps! Let me know if you run into any issues.

yo, i’ve been messin with notion calendars too. u gotta add a date property to ur code, like this:

Date: {
type: ‘date’,
date: {
start: ‘2023-05-20’
}
}

put that in ur properties object and ur good to go. just change the date to whatevr u need.

To add dates to your Notion Calendar events, you’ll need to modify your code slightly. In the properties object, include a ‘Date’ field with the appropriate date information. Here’s an example of how you can structure it:

properties: {
  Name: {
    type: 'title',
    title: [{ type: 'text', text: { content: eventName } }]
  },
  Date: {
    type: 'date',
    date: {
      start: '2023-05-20',
      end: '2023-05-20'
    }
  }
}

Replace the date strings with your desired event dates. If you need to work with dynamic dates, you can use JavaScript’s Date object to generate the appropriate strings. This approach should successfully add both the event name and date to your Notion Calendar.