Python 특정 일이 속한 Week 계산

2021. 12. 1. 19:30서버 프로그래밍

 

import datetime

def AddDays(sourceDate, count):
	targetDate = sourceDate + datetime.timedelta(days = count)
	return targetDate
    
def GetWeekFirstDate(sourceDate):
	temporaryDate = datetime.datetime(sourceDate.year, sourceDate.month, sourceDate.day)
	weekDayCount = temporaryDate.weekday()
	targetDate = AddDays(temporaryDate, -weekDayCount);
	return targetDate

https://icodebroker.tistory.com/6852

 

[PYTHON/DATETIME] 특정일이 속하는 주(Week)의 첫번째 날짜(월요일) 구하기

import datetime def AddDays(sourceDate, count): targetDate = sourceDate + datetime.timedelta(days = count) return targetDate def GetWeekFirstDate(sourceDate): temporaryDate = datetime.datetime(sourc..

icodebroker.tistory.com