Dhinagaran S
Dhinagaran S

Reputation: 13

How to convert date format from ddmmyyyy to dd.mm.yyyy base on eclipse python robot framework

I am getting date in this format 20210701 and I want to convert it to this format 01.07.2021

Upvotes: 0

Views: 589

Answers (2)

Todor Minakov
Todor Minakov

Reputation: 20057

You can use the standard library DateTime and Convert Date in it - specify the format of your input date, and the format you want it processed in:

${bb}=    Convert Date    20210701  date_format=%Y%m%d      result_format=%d.%m.%Y    
Log To Console    ${bb]    # prints "01.07.2021"

Upvotes: 2

Jiri Janous
Jiri Janous

Reputation: 1242

If it is a string and not date like object, you can simply format it with string library. like so

***Settings***
Library    String
***Variables***
${date}    20210701
*** Test Cases ***
Format date
    @{characters}=    Split String To Characters    ${date}
    Log    ${characters}[6]${characters}[7].${characters}[4]${characters}[5].${characters}[0]${characters}[1]${characters}[2]${characters}[3]

Upvotes: 2

Related Questions