According to the documentation of datetime.strptime() https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior, technical note (4), %f accepts only 1 - 6 chars:

%f is an extension to the set of format characters in the C standard (but implemented separately in datetime objects, and therefore always available). When used with the strptime() method, the %f directive accepts from one to six digits and zero pads on the right.

I do NOT believe you have solved the problem correctly. You should not prefix the string with zero, but instead drop everything past 6 (which is less significant to contributing to time).

Something like this:

s='2014-11-19 00:00:00.0000000'
print (datetime.datetime.strptime((s[:26]).strip(), '%Y-%m-%d  %H:%M:%S.%f')).date()
Answer from user590028 on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-use-strptime-with-milliseconds-in-python
How to use strptime with milliseconds in Python - GeeksforGeeks
July 23, 2025 - Here's how to do it: ... from datetime ... = datetime.strptime(s, format) print(dt_obj) ... Use %f when you want to include milliseconds or microseconds in your datetime string....
🌐
Python documentation
docs.python.org › 3 › library › datetime.html
datetime — Basic date and time types
Added in version 3.7. Changed in version 3.11: Previously, this method only supported formats that could be emitted by time.isoformat(). ... Return a time corresponding to date_string, parsed according to format. If format does not contain microseconds or timezone information, this is equivalent to: ... ValueError is raised if the date_string and format cannot be parsed by time.strptime() or if it returns a value which is not a time tuple.
🌐
GitHub
github.com › selectel › tempo › issues › 1
milliseconds in strptime and strftime · Issue #1 · selectel/tempo
June 25, 2012 - For example: (tempo_dev@garry-... line 115) Also, there is no way to set right format, because strptime and strftime do not support milliseconds....
Author   2garryn
🌐
TutorialsPoint
tutorialspoint.com › how-to-use-strptime-with-milliseconds-in-python
How to use strptime with milliseconds in Python
October 13, 2023 - The Python time strptime() method parses a string representing a time, either in UTC or local time, according to a format. The method accepts two arguments: one being the time to be parsed as a string and the other argument is the format specified.
🌐
GitHub
github.com › getsentry › sentry › issues › 1610
Timestamp parsing fails when the microseconds part is longer than 6 digits · Issue #1610 · getsentry/sentry
July 15, 2015 - Discarded invalid value for timestamp: ... u'2015-07-15T11:39:37.0341297Z' The cause is that the Python strptime implementation only supports up to 6 digits for the fraction part:...
Author   cmlenz
🌐
Esri Community
community.esri.com › t5 › python-questions › milliseconds-with-strftime › td-p › 73258
Solved: Milliseconds with strftime - Esri Community
December 10, 2021 - I need to return time to the millisecond;Python strftime reference provides the %f format place holder, but when I use it in Python 3.x it fails. This works: from time import strftime site = 'FP 20180822' for i in range(1,10): theTime = strftime("%H%M%S") newTime = '{} {}'.format(site,theT...
Find elsewhere
🌐
Delft Stack
delftstack.com › home › howto › python › python datetime milliseconds
How to Convert DateTime to String With Milliseconds in Python | Delft Stack
February 2, 2024 - We can also simply remove the last three digits from the string to get the final result in milliseconds. Consider a scenario where you need to capture the current date and time, transforming it into a string with milliseconds for further processing or display. Python provides a built-in solution using the str() method.
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-parse-a-time-string-containing-milliseconds-in-python
How to Parse a Time String Containing Milliseconds in Python? - GeeksforGeeks
July 23, 2025 - Python's datetime module provides classes for manipulating dates and times. The most commonly used classes are datetime, date, time, and timedelta. These classes allow us to perform various operations, from simple date and time arithmetic to complex formatting and parsing of time strings. ... When dealing with time strings that include milliseconds, the datetime class is particularly useful. We can use the strptime method to parse a string into a datetime object, specifying the exact format of our time string.
🌐
WordPress
mike632t.wordpress.com › 2021 › 05 › 02 › formatting-time-with-milliseconds-in-python
Formatting time with milliseconds in Python | Notes on Linux
May 2, 2021 - >>> _now = time.time() >>> print ("Time : %s.%s\n" % (time.strftime('%x %X',time.localtime(_now)), ... str('%.3f'%_now).split('.')[1])) # Rounds to nearest millisecond Time : 05/02/21 01:16:58.676 >>> The nice thing about this approach is that because the number of seconds is being formatted as a float the fractional part will be rounded correctly regardless of the number of decimal places used. >>> print ("Time : %s.%s\n" % (time.strftime('%x %X',time.localtime(_now)), ... str('%.1f'%_now).split('.')[1])) # Rounds to nearest tenth of a second Time : 05/02/21 01:16:58.7 >>>
🌐
py4u
py4u.org › blog › python-time-milli-seconds-calculation
How to Calculate Milliseconds in Python Using datetime Module: A Practical Guide
If you have a timestamp string with milliseconds (e.g., "2024-05-20 15:30:45.123"), use datetime.strptime() with the %f directive to parse microseconds. Then convert to milliseconds.
🌐
Python
docs.python.org › 3 › library › time.html
time — Time access and conversions
The locale setting affects the interpretation of many format specifiers in strftime() and strptime(). ... General calendar-related functions. timegm() is the inverse of gmtime() from this module. ... The use of %Z is now deprecated, but the %z escape that expands to the preferred hour/minute offset is not supported by all ANSI C libraries. Also, a strict reading of the original 1982 RFC 822 standard calls for a two-digit year (%y rather than %Y), but practice moved to 4-digit years long before the year 2000.