Given any date, find the last date of the week in Python

Posted by Rajnilari2015 under Python category on | Points: 40 | Views : 29
Given a date like "9/23/2016", find the last date of the week. The below code will do so

from System import *
from System.Globalization import *

class Program(object):
def Main(args):
initialDate = Convert.ToDateTime("9/23/2016")
lastDayOfWeek = initialDate.AddDays(CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek - initialDate.DayOfWeek).AddDays(6)

Main = staticmethod(Main)

Comments or Responses

Login to post response