Menu

gitpiper

days_ago python Code Snippet in 2024

dateintermediate

Last Updated: 14 December 2024

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 December 2024

Subscribe to our Newsletter

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

© 2024 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! ✌️