I have to split a date time which I get from a software in the below format to separate variables (year,month,day,hour, min,sec)
19 Nov 2015 18:45:00.000
Below solution should work for you:
import datetime
string = "19 Nov 2015 18:45:00.000"
date = datetime.datetime.strptime(string, "%d %b %Y %H:%M:%S.%f")
print date
Output would be:
2015-11-19 18:45:00
And you can access the desired values with:
>>> date.year
2015
>>> date.month
11
>>> date.day
19
>>> date.hour
18
>>> date.minute
45
>>> date.second
0
You can check datetime's package documentation under section 8.1.7 for srtptime function's usage.