Datetime difference to return Days only?
Question: 
    $ cat .t.py 
    import re
    from datetime import datetime as dtt
    
    oldestDate = dateComp = dtt.strptime('1.1.1001', '%d.%m.%Y')
    dateComp = dtt.strptime('11.1.2011', '%d.%m.%Y')
    ind = re.sub(" days,.*", "", str((dateComp - oldestDate)))
    
    print ind
    print dateComp - oldestDate
    $ python .t.py 
    368905
    368905 days, 0:00:00
    

How can I get days only without the regex code-smell? The problem escalate
because I need to use the index in many locations. So some cleaner way to do
this?


Answer: Don't use `str()` so soon. The result you get back from subtracting one
`datetime` from another is a
[`timedelta`](http://docs.python.org/library/datetime.html#timedelta-objects)
object, which has a `.days` property that you can read.

    
    
    (dateComp - oldestDate).days
    

Note that reading _only_ the `.days` property will mean that it will round
down the difference - if you instead want to round to the nearest number of
days, you'll need to add some logic to check the `.seconds` property to see
whether it's closer to 0 or 86400.

