cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot convert date expectedly with FormatDate function

ShoheiOtsu
Level 2
Hi, 

I would like to convert the date as per below, but it doesn't work. I'm using 6.10.3 in Japan.

My Expectation
Function : FormatDate("2022/10/23", "ddMMMyy")
Result : "23Oct22"

Current Actual
Function : FormatDate("2022/10/23", "ddMMMyy")
Rsult : "231022"

I do not know why this function behaves like this, which deos not follow the specification from BluePrism official definition. I hope your help, anyone.

Thanks for reading.

------------------------------
Shohei Otsu
------------------------------
5 REPLIES 5

PvD_SE
Level 12
Hi S,

We are on 6.10.5 but I gave it a try anyway. I tried the following:
  • FormatDate(Today(), "ddMMMyy") which gives "24Oct22"
  • FormatDate(Today(), "ddMMyy") that gives "241022"
Are you sure you use MMM and not MM in you example?

------------------------------
Happy coding!
---------------
Paul
Sweden
------------------------------
Happy coding!
Paul, Sweden
(By all means, do not mark this as the best answer!)

MichealCharron
Level 8
@ShoheiOtsu

The DateTimeFormatInfo.AbbreviatedMonthNames property for the culture setting ja-JP is defined as numbers. You won't get month abbreviations.


------------------------------
Micheal Charron
Senior Manager
RBC
America/Toronto
------------------------------
Micheal Charron
RBC
Toronto, Ontario
Canada

@Micheal Charron
Oh, ok. I will search other method which meets my requirement.​ Thank you for the information

@Paul JHM van Doorn
​Thank you for the response. My question is resoved as per Micheal's answer.

------------------------------
Shohei Otsu
------------------------------

@ShoheiOtsu

If you want to keep it as a calculation, might I suggest:

FormatDate([Source Date],"dd") & Mid("JanFebMarAprMayJunJulAugSepOctNovDec", ((ToNumber(FormatDate([Source Date],"MM"))-1) * 3)+1, 3) &  FormatDate([Source Date],"yy")


It's ugly but it works.



------------------------------
Micheal Charron
Senior Manager
RBC
America/Toronto
------------------------------
Micheal Charron
RBC
Toronto, Ontario
Canada

@MichealCharron
I tried it and confirmed it works!! Thank you for the instruction.​

------------------------------
Shohei Otsu
------------------------------