# toordinal() Function Of Datetime.date Class In Python

• Last Updated : 23 Aug, 2021

The toordinal() function is used to return the proleptic Gregorian ordinal of a specified datetime instance.

Note: The Proleptic Gregorian ordinal gives the number of days elapsed from the date 01/Jan/0001. And here ordinal is called Proleptic since the Gregorian calendar itself is followed from October 1582.

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

Syntax: toordinal()

Parameters: This function does not accept any parameter.

Return values: This function returns the proleptic Gregorian ordinal of a datetime instance.

Example 1: Using today’s date.

## Python3

 `# Python3 code to demonstrate``# Getting the proleptic Gregorian``# ordinal of a datetime instance`` ` `# importing datetime and time module``import` `datetime``import` `time`` ` `# Getting today's date``todays_Date ``=` `datetime.date.fromtimestamp(time.time());`` ` `# Calling the toordinal() function over the``# today's date``date ``=` `todays_Date.toordinal();`` ` `# Printing the proleptic Gregorian ordinal``# for the today's date``print``(``"Proleptic Ordinal for today's date: %s"``%``date);`

Output:

`Proleptic Ordinal for today's date: 737998`

Example 2: Using today’s date and time.

## Python3

 `# Python3 code to demonstrate``# Getting the proleptic Gregorian``# ordinal of a datetime instance`` ` `# importing datetime and time module``import` `datetime``import` `time`` ` `# Getting today's date and time``todays_DateTime ``=` `datetime.datetime.now();`` ` `# Calling the toordinal() function over the``# today's date and time``DateTime ``=` `todays_DateTime.toordinal();`` ` `# Printing the proleptic Gregorian ordinal``# for the today's date and time``print``(``"Proleptic Ordinal for today's date and time: %s"``%``DateTime);`

Output:

`Proleptic Ordinal for today's date and time: 737998`

Example 3: Using a specific date.

## Python3

 `# Python3 code to demonstrate``# Getting the proleptic Gregorian``# ordinal of a datetime instance`` ` `# importing datetime and time module``import` `datetime``import` `time`` ` `# Initializing a date and time``DateTime ``=` `datetime.datetime(``1358``, ``8``, ``12``, ``1``, ``3``, ``4``, ``9``);`` ` `# Calling the toordinal() function over the``# above date and time``Date_Time ``=` `DateTime.toordinal();`` ` `# Printing the proleptic Gregorian ordinal``# for the above given date and time``print``(``"Proleptic Ordinal for today's date and time: %s"``%``Date_Time);`

Output:

`Proleptic Ordinal for today's date and time: 495858`

My Personal Notes arrow_drop_up