This really shouldn't be this hard but for some reason I can't seem to get it.
I am trying to run a filter on my query that compares the date range between today, and the first day of next year.
Getting today is no problem, but I can't seem to get the first day of next year. I want to be able to provide myself with Jan 1/2013
Here is my filter so far:
cur_il = Investment.objects.all().filter(plan = plan).order_by('financial_institution').filter(maturity_date__range=[now, nextyear])
Obviously I use this to get today's date:
now = datetime.now()
How can I get the next date?
Does this work?
>>> today = datetime.datetime.now()
>>> next_year = datetime.datetime(year=today.year+1, month=1, day=1)
>>> next_year
datetime.datetime(2013, 1, 1, 0, 0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With