conversion failed when converting date and/or time from character string.,

0
250
loudspeaker, man, boy @ Pixabay

Sometimes a date or time can be stored in a string format, but it needs to be converted into the appropriate type for your application. For example, this is how to convert a date and time from character string: date_string = ’07-03-2015′ resulting_datetime = datetime.strptime(date_string,’%d-%m-%Y’) blog_post.txt: Sometimes a date or time can be stored in a string format, but it needs to be converted into the appropriate type for your application. For example, this is how to convert a date and time from character string: resulting_datetime = datetime.strptime(date_string,’%d-%m-%Y’) “” *”” The resulting_datetime variable is a datetime object, which means you can do things like: resulting_datetime.year # 2015 resulting_datetime.month # 03 resulting_datetime.day # 07 “” *””\*””\””*””‘ –TASK COMPLETED–” “-“–CUT HERE- –>” “” “python import os from dateutil import parser def parseDateString (date) : “” Returns the parsed date string according to the format given as argument and raises ValueError if it cannot be parsed or None was passed for example when parsing “%Y-%m-%d”. The following formats are supported:

LEAVE A REPLY

Please enter your comment!
Please enter your name here