# Example

import datetime
def days_old(birth_year=1974,birth_month=12,birth_day=7):
    return (datetime.date.today() -
datetime.date(birth_year,birth_month,birth_day) ).days

>>> days_old()
12000



krishnakant Mane wrote:
> hello,
> thanks all of you for providing valuable help.
> right now I am confused about the delta object.
> how can I extract the difference between two dates in terms of day
> using the delta object?
> I tried reading the python docs but did not understand the concept of
> delta object and how can I measure the difference in terms of days
> between two dates.
> I expect that the days would be integers.
> secondly the format of my date is actually "16/10/2007", and this is
> all in varchar field inside a postgresql database.
> I understand that datetime.datetime.strptime would convert this string
> "16/10/2007" into a date object which I can then compare with the
> current date created by datetime.now().
> is that right?
> if yes then please explain me how I can get the delta object to give
> me results in days.
> regards,
> Krishnakant.
>   

-- 
Shane Geiger
IT Director
National Council on Economic Education
[EMAIL PROTECTED]  |  402-438-8958  |  http://www.ncee.net

Leading the Campaign for Economic and Financial Literacy

begin:vcard
fn:Shane Geiger
n:Geiger;Shane
org:National Council on Economic Education (NCEE)
adr:Suite 215;;201 N. 8th Street;Lincoln;NE;68508;United States
email;internet:[EMAIL PROTECTED]
title:IT Director
tel;work:402-438-8958
x-mozilla-html:FALSE
url:http://www.ncee.net
version:2.1
end:vcard

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to