Good Day Knimers
Is it possible to get only year and month as date format?
Example:2021/09 - YYYY/MM (date data type)
Thanks a lot
Good Day Knimers
Is it possible to get only year and month as date format?
Example:2021/09 - YYYY/MM (date data type)
Thanks a lot
Hello @Karlygash,
simply use yyyy/MM
in Date&Time to String node. This is under assumption that your date is in column type Local Date. Note that any other Date(&Time) format different than default (yyyy-MM-ddβ¦) must be in string column. So when working with date (and time) information itβs best to keep it in Local Date (Time) column type so you can utilize Date&Time nodes (e.g. Date&Time Difference node) and prior to export/visualization convert it to string format you want/need.
Br,
Ivan
Hi @ipazin , I think @Karlygash is trying to achieve the other way around.
The way I understood it is that the data is like β2021/09β as string, and @Karlygash wants to convert the data type to date, so converting string β2021/09β to a date format.
@Karlygash , I donβt think that is possible as this is not a valid date. What is the purpose of doing this? Could you append β/01β to all of these to make it a valid date string? So β2021/09β would have to be transformed to β2021/09/01β first.
But as I mentioned, perhaps understanding the purpose behind this can help determine what the best solution would be.
@bruno29a @ipazin
Good Evening)
Yes, actually I added β/01β and converted them into date format.
In that case I could compare two date formats
Thanks a lot
Hi @Karlygash , if you need to compare dates to retrieve difference between them in different granular (days, months, year, etc), then yes you need to convert, and you figured out with the β/01β.
If you just need to compare to see which date is smaller or bigger (earlier or later), you can compare as string, as long as your format is in YYYY followed by MM (any separator in between does not matter, whether β-β or β/β or any other). For example, as string, β2021/08β is smaller than β2021/09β in the sense that alphabetically ordered, β2021/08β comes before β2021/09β.
So, you can actually evaluate that β2021/08β < β2021/09β.
Hereβs a test workflow that tests this via Column Expressions and Rule Engine:
Input data:
Column Expressions is set as this:
if(column("column1") > column("column2")) {
"Greater"
} else if(column("column1") < column("column2")) {
"Less"
}
Results:
On the other side, Rule Engine is set up like ths:
$column1$ > $column2$ => "Greater"
$column1$ < $column2$ => "Less"
TRUE => "Same"
Results:
So, as you can see, you can compare strings in that sense.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.