End of Summer - hours only!Up to 80% off on all courses and bundles.-Close
5. Creating date objects


Now that we know the basics of time objects, let's move on to dates. They are created in a similar way:

fra_mad_scheduled = datetime.date(2018, 12, 1)
print('Date:', fra_mad_scheduled)
print('Year:', fra_mad_scheduled.year)
print('Month:', fra_mad_scheduled.month)
print('Day:', fra_mad_scheduled.day)

In the code above, we create a simple date object that represents December 1st, 2018. And just like with time objects, we can get a single date element (year, month, or day) using the dot operator.


Daniel Higgins started working for our company on July 2nd, 2018. Create a variable named higgins_start_date that will contain a date object pointing to his first day at work. Use the variable to print the following sentence:

Daniel Higgins has been working for us since {date}

Stuck? Here's a hint!

To create the date object, use

datetime.date(2018, 7, 2)