1
votes

I am using Robot framework and I want to get previous date. I am doing it as given below.

Getdate is a variable which holds current date, and Date2 holds the value after subtraction.

    ${Getdate}=  |  Get Current Date | result_format=%m/%d/%Y
    ${Date2}=    |  Evaluate | ${Getdate} - {00/01/0000}
    Log ${Date2} |

However I am getting an error. Could someone help me with getting the previous date using Robot framework?

2

2 Answers

2
votes

Got the answer. I was using the wrong keyword. It should be done using keyword "Subtract Time From Date". Below is the code.

${Getdate}= |   Get Current Date
${Date2}=   |   Subtract Time From Date |${Getdate} |1day|result_format=%m/%d/%Y
Log|${Date2}
2
votes

Also it should be possible to do that using:

${date} =    Get Current Date    result_format=%m/%d/%Y    increment=-1 day
Log    ${date}