← Back to team overview

sikuli-driver team mailing list archive

[Question #209704]: datetime, compare 2 dates, can this be done a smarter way?

 

New question #209704 on Sikuli:
https://answers.launchpad.net/sikuli/+question/209704

I've checked http://docs.python.org/library/datetime.html, but can't seem to get two dates to compare to each other in a smart way.

What I need is to copy a date from an Excelsheet and compare it to todays date, to find out if a case is due or not.
What I have is this and that's hardly optimal:
 
import datetime

# This is the date/time i get from Excel and is just set here to get a working example:
duedate = "26-09-2012 00:00:00"

#Setting date, month and year to 3 strings
datoNow = str(datetime.datetime.now().strftime("%d"))
MDNow = str(datetime.datetime.now().strftime("%m"))
AarNow = str(datetime.datetime.now().strftime("%Y"))

if not duedate == "-":
    Temp1 = duedate.split(" ")
    Temp2 = Temp1[0].split("-")
    dato, MD, Aar = Temp2[0], Temp2[1], Temp2[2]

    if AarNow >= Aar and MDNow >= MD and datoNow > dato:
        print ("This is due")



-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.