Select to view content in your preferred language

Unable to parse input

1379
2
05-24-2021 09:47 AM
CliveSwan
Frequent Contributor

Greetings,

I am trying to parse a date filed in YYYY-MM-DD format, get an input error??

The code is:

    fromTime = 0
    while fromTime == 0:
        ###fromTime = raw_input("Start date of total requests in YYYY-MM-DD HH:MM format (e.g. 2014-05-10 14:00): ")
        ##YYYY-MM-DD HH:MM format.
        fromTime = ("2021-05-20 08:00: 2021-05-20 08:00")
        # Convert input to Python struct_time and then to Unix timestamp in ms
        try:
            fromTime = int(time.mktime(time.strptime(fromTime, '%Y-%m-%d %H:%M')) * 1000)
        except:
            print('Unable to parse input. Ensure date and time is in YYYY-MM-DD HH:MM format.')
            fromTime = 0

 

The ToTime = 2021-05-21 08:00

I don't get why I get the input time error??

Any pointers would be appreciated.

The error is:

Unable to parse input. Ensure date and time is in YYYY-MM-DD HH:MM format.
Unable to parse input. Ensure date and time is in YYYY-MM-DD HH:MM format.
Unable to parse input. Ensure date and time is in YYYY-MM-DD HH:MM format.

 

 

Tags (3)
0 Kudos
2 Replies
DavidPike
MVP Frequent Contributor

Look at your fromTime, it's repeated for some reason.

CliveSwan
Frequent Contributor

Hi David,

It was supposed to be a variable holder, to reference the input.

Thanks,

Clive

0 Kudos