LoslegenKostenlos loslegen

Working with the datetime library

We will be exploring the datetime library, specifically the datetime.strptime(date_string, format) method that converts a string date in a specific string format by identifying day, month and year. Using the table provided, determine the appropriate code to identify the year, month, and day from the dates below (you can check your answers by printing the method in the console):

  • 12-01-1990 (US Format m-d-y)
  • 23/08/2020 (EU Format d-m-y)
Directive Meaning Example
%d Day of the month as a zero-padded decimal number 01, 02, …, 31
%b Month as locale’s abbreviated name Jan, Feb, …, Dec
%B Month as locale’s full name January, …, December
%m Month as a zero-padded decimal number 01, 02, …, 12
%y Year without century as a zero-padded decimal number 00, 01, …, 99
%Y Year with century as a decimal number 1970, 1988, 2001, 2013

Diese Übung ist Teil des Kurses

Financial Forecasting in Python

Kurs anzeigen

Interaktive Übung

Setze die Theorie in einer unserer interaktiven Übungen in die Praxis um

Übung starten