Value error for format while using data_format option

Viewed 51

I am new and I am trying to get our required date_format. I Tried to check other formats in date_format also. But i am getting this error.

ValueError: time data '2018-11-16 11:18:58' does not match format '%m/%d/%Y %I:%M:%S %p'

This is generated by the following script:

Robot Test Suite

    *** Settings ***
    Library  DateTime

    *** Variables ***
    ${UTC_OFFSET}  - 5 hours
    ${LOCAL_TIME_ZONE}  -05:00
    ${LOCAL_DATE_FORMAT}  %m/%d/%Y

    *** Test Cases ***
    Test title
        ${Supplied_Date}=  DateTime.Get Current Date  time_zone=UTC  increment=${UTC_OFFSET}  result_format=%Y-%m-%d %H:%M:%S
        Log  ${Supplied_Date}  console=true
        ${Supplied_Date}  DateTime.convert date  ${Supplied_Date}    result_format=%Y-%m-%d %H:%M:%S   exclude_millis=${True}   date_format=${LOCAL_DATE_FORMAT} %I:%M:%S %p
        Log  ${Supplied_Date}  console=true
1 Answers

Simple mix-up of the result_format and date_format values:

*** Settings ***
Library  DateTime

*** Variables ***
${UTC_OFFSET}  - 5 hours
${LOCAL_TIME_ZONE}  -05:00
${LOCAL_DATE_FORMAT}  %m/%d/%Y

*** Test Cases ***
Test title
    ${Supplied_Date}=  Get Current Date  
    ...    time_zone=UTC  
    ...    increment=${UTC_OFFSET}  
    ...    result_format=%Y-%m-%d %H:%M:%S
    Log  ${Supplied_Date}  console=true

    ${Supplied_Date}  Convert Date  
    ...    ${Supplied_Date}    
    ...    date_format=%Y-%m-%d %H:%M:%S   
    ...    exclude_millis=${True}   
    ...    result_format=${LOCAL_DATE_FORMAT} %I:%M:%S %p
    Log  ${Supplied_Date}  console=true
Related