Convert string of dd-MON-yy to date in Python

Jim Macaulay

I have a string in dd-MON-yy format. While converting to date in python, its is causing issue since the year is in tow digits.

datetime.datetime.strptime('17-JUN-03', '%d-%m-%y')

The error is,

ValueError: time data '17-JUN-03' does not match format '%d-%m-%y'
user56700

Try this:

import datetime
print(datetime.datetime.strptime('17-JUN-03', '%d-%b-%y'))

Result:

2003-06-17 00:00:00

Datetime format codes

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Convert date from DD-MON-YY to YYYYMMDD

Regular expression convert Date format from dd-mon-yy to dd/MM/yy

Browser independent String(DD-MON-YY) to Date conversion

puzzled with how to convert ddmmyy string to dd-MMM-yy date

want to convert string mm/dd/yy to date yyyy/mm/dd format in Sybase

Convert Timestamp string (dd MMM yyyy HH:mm:ss) to Date (DD/MM/YY) in Google Sheets

oracle convert DD-MON-YY to DD/MM/YYYY

PHP convert date to DD-M-YY

Convert date with format dd.mm.yy to yyyy-mm-dd in python

Convert date string dd-mm-yy to moment.js valid date

Convert Date String from YYYYMMDD to DD Mon YYYY

Converting string format dd - mmm - yy to date

How To Convert String ' dd/mm/yy hh:MM:ss ' to Date in javascript?

Convert json string to date in dd-mm-yy format using javascript

Convert string timestamp mm/dd/yy hh:mm:ss to a date/time type in google sheets

AWS Athena (Trino SQL) Convert birthdate string (mm/dd/yy) to date -- need twentieth century

Sql Server Date Format DD-Mon-YY

How can verify if a date is in the format dd mon ' yy in Ruby?

How to convert date format "dd/mm/yy" to "yy/mm/dd" for mysql database inserting?

How to convert date dd/mm/YY to mm-dd-YY format in PHP

Check if input string contains date(specially in the format yy-mm-dd) using python

how to convert date to yy-mm-dd in scala

Excel - Convert date from yymmdd to dd/mm/yy

The simplest way to convert a long date format to YY/MM/DD HTML

How to convert the given date to dd-mm-yy format in javascript?

Excel - convert part of filename to mm/dd/yy date

Python: convert date format YYYY-mm-dd to dd-MON-yyyy with abbreviated month

Convert a formmated string (dd/mm/yy) to and ISO datetime

Date conversion form string dd/mm/yy is failing