(older archive entries before 2007 are not shown here, but included in the onsite-search)
Mailing List - Entries of 2014
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [QF-Test] need Sunday of the current week (please help)
On 12/02/2014 12:52 AM, Yi Li wrote: I’m trying to come up with a script that needs end date for the current week (i.e Sunday). Can someone help me please? Here is a copy from my Jython terminal: >>> from datetime import date, timedelta >>> today = date.today() >>> days_until_sunday = 6 - today.weekday() >>> sunday = today + timedelta(days_until_sunday) >>> >>> today datetime.date(2014, 12, 2) >>> today.weekday() 1 >>> days_until_sunday 5 >>> sunday datetime.date(2014, 12, 7) The weekday is 0 for Monday and 6 for Sunday. If you run this on a Sunday, both "today" and "sunday" will be the same day. Hope that helps, - Michael
|