views:

59

answers:

3

Hi, the title says nearly all I want: How do I convert a datetime.datetime object (e.g. the return value of datetime.datetime.now()) to a datetime.date object in Python?

+1  A: 

The documentation is your friend.

datetime.datetime.date()

Return date object with same year, month and day.

delnan
+2  A: 

use the date method:

datetime.datetime.now().date()
ars
A: 

You use the datetime.datetime.date() method:

datetime.datetime.now().date()

Obviously, the expression above can (and should IMHO :) be written as:

datetime.date.today()
ΤΖΩΤΖΙΟΥ