9951 explained code solutions for 126 technologies


pythonHow to get day from date


import datetime
date = '2022-10-20 10:11:12'
day = datetime.datetime.strptime(date, "%Y-%m-%d %H:%M:%S").dayctrl + c
datetime

module to manipulate dates/times

date =

example date to extract part from

datetime.datetime.strptime

parses given string with the given format

"%Y-%m-%d %H:%M:%S"

format of the datetime string to parse

.day

returns day part of the date