user3303266
user3303266

Reputation: 371

RobotFramework - converting a date that has milliseconds in it

I'm converting the following date

${converted_randomization_date}=  Convert Date  2017-01-03 00:00:00.000  date_format=%Y-%m-%d %H:%M:%S.%s  result_format=%Y-%M-%d  exclude_millis=False

But getting the following error:

ValueError: 's' is a bad directive in format '%Y-%m-%d %H:%M:%S.%s'

Why is this? Are milliseconds not represented by %s

Upvotes: 1

Views: 1474

Answers (1)

Todor Minakov
Todor Minakov

Reputation: 20057

Use %f for the microseconds - don't worry you're actually providing milliseconds there, that's the python's formatting string for them.

${converted_randomization_date}=  Convert Date  2017-01-03 00:00:00.000  date_format=%Y-%m-%d %H:%M:%S.%f  result_format=%Y-%M-%d  exclude_millis=False
Log To Console  ${converted_randomization_date}
# logs   2017-00-03

Upvotes: 4

Related Questions