简体   繁体   English

如何使用机器人框架获取以前的日期?

[英]how to get previous date using robot framework?

I am using Robot framework and I want to get previous date. 我正在使用Robot框架,我希望得到以前的日期。 I am doing it as given below. 我这样做如下。

Getdate is a variable which holds current date, and Date2 holds the value after subtraction. Getdate是一个保存当前日期的变量,Date2保存减法后的值。

    ${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? 有人可以帮助我使用Robot框架获取之前的日期吗?

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}

Also it should be possible to do that using: 也应该可以使用以下方法:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM