Pretty formatting of long string
Question: The string

    
    
    date2check = to_datetime(str(last_tx.year) + \
                            '-' + str(int(last_tx.month)-3) + \
                            '-' + str(last_tx.day) + \
                            ' ' + str(last_tx.hour) + \
                            ':' + str(last_tx.minute) + \
                            ':' + str(last_tx.second))
    

works without problem but I want to know if there is some way to re-write this
more appropiately (in a pythonic way). `last_tx` is a datetime object.


Answer: A pythonic way is using `datetime` module in order to get the date of 3 moth
ago:

    
    
    datetime.strftime(last_tx-timedelta(90),'%Y-%m-%d %H:%M:%S')
    

Here is an example:

    
    
    >>> from datetime import datetime, timedelta
    >>> datetime.now()
    datetime.datetime(2016, 5, 23, 23, 3, 34, 588744)
    >>> datetime.strftime(datetime.now()-timedelta(90),'%Y-%m-%d %H:%M:%S')
    '2016-03-24 23:03:38'
    

As @ sparkandshine mentioned in comment, since 90 doesn't always represent 3
month you can use `dateutil.relativedelta` in order to achieve an exact match.

