I need to convert the YYYYMM to YYYY-MM-01 using azure data factory pipeline expression.
I tried the below expression but it giving me error that date value should follow the ISO 8601 format.
@formatDateTime(concat('202301','01'),'YYYY-MM-DD')
It should return in this format ‘2023-01-01’.
Thanks
4
Answers
I used multiple substring to get this as shown below, if any better answer please let me know.
You can supply a format string including numbers to
formatDateTime
, for example:NB You have the case of your argument wrong, it should be lower-case y for Year, upper-case M for month and lower-case d for Day.
Instead of concatenating 202301 with 01 (three times) and then taking substring, you can use the below expression to achieve the same.
Just a simpler way , then what you have used.
The issue here is the
is missing the "-" but
Just works fine.
I am not sure as to what is the Source here , if it is query then you can get the yyyymm in the form of yyyy-mm and that should help .
Also I request to have a look on the startOfMonth function .
https://learn.microsoft.com/en-us/azure/data-factory/control-flow-expression-language-functions#startOfMonth