Python with Excel

Viewed 19

Below I am trying to compare the date from Excel with the current date from Local PC if match them will print ( match ) but I got below result always I guess because time always comes with Date from Excel so will not match, can anyone guide me plz, how to remove time from excel to compare it as you know I changed format from Excel as it came as float

2021-11-11 00:00:00 2021-11-11 00:12:51.282034 Date not missed

enter code here
 import datetime
import xlrd
import datetime
from xlrd import open_workbook
book = open_workbook('D:/ma.xls')
sheet = book.sheet_by_index(0)
d=(sheet.cell_value(0,1))
a11 = datetime.datetime(*xlrd.xldate_as_tuple(d, book.datemode))
a1=str(a11)
d=datetime.datetime.strptime(a1,"%Y-%m-%d %H:%M:%S") print(d)

CurrentDate = datetime.datetime.now() enter code here print(CurrentDate) if CurrentDate == d: print("match") else: print("Date not match")

0 Answers
Related