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

Rajnilari2015
Posted by Rajnilari2015 under Python category on | Points: 40 | Views : 943
Given a date like "9/23/2016", find the first 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")
firstDayOfweek = initialDate.AddDays(CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek - initialDate.DayOfWeek)
Console.ReadKey()

Main = staticmethod(Main)

Comments or Responses

Login to post response