• Как рассчитать от даты до даты?

    LazyTalent
    @LazyTalent
    Data Engineer, Freelancer
    >>> import datetime
    >>> from dateutil import relativedelta
    >>> past_date = '2017-07-31'
    >>> past_date = datetime.datetime.strptime(past_date, '%Y-%m-%d')
    >>> today = datetime.datetime.now()
    >>> diff = relativedelta.relativedelta(today, past_date)
    >>> f'{diff.years} years, {diff.months} months and {diff.days} days'
    '2 years, 8 months and 17 days'
    Ответ написан
    Комментировать