Changing date format after converting from int value in python

Can I change the date format from (YYYY, MM, DD) to (DD, MM, YYYY).

import datetime    
date_value = 41381.0    
date_conv= datetime.date(1900, 1, 1) + datetime.timedelta(int(date_value))    
print date_conv

conclusion:

date_conv = 2013-04-19

Convert python date formats - Unusual date formats - Extract% Y% M% D

The current output is in the (YYYY, MM, DD) formate.

+5
source share
2 answers
>>> import datetime
>>> date_value = 41381.0
>>> date_conv= datetime.date(1900, 1, 1) + datetime.timedelta(int(date_value))
>>> print date_conv.strftime('%d-%m-%Y')
19-04-2013
+5
source
print date_conv.strftime('%d.%m.%Y')

prints the date in format DD.MM.YYYY. More formatting options here .

+6
source

All Articles