Menu

gitpiper

days_ago python Code Snippet in 2022

dateintermediate

Last Updated: 25 September 2022

Calculates the date of n days ago from today.

  • Use datetime.date.today() to get the current day.
  • Use datetime.timedelta to subtract n days from today's date.
from datetime import timedelta, date def days_ago(n): return date.today() - timedelta(n)
days_ago(5) # date(2020, 10, 23)

python snippet similar to days_ago For You in September 2022

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2022 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️