Python: Convert datetime to date

In order to do date comparisons, you need to convert your datetime to a date object.

To do that, simply call date() from your datetime object.

now = datetime.datetime.now()
now_date = now.date()

I know, bad example because I could have used datetime.date.today() instead.

tumblr_kp591vlknj1qzxzwwo1_500
Now, if only I could handle time like Sean Connery...

Source

 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog