Extract year, month and financial year from date

Hi!! Knime experts…
Hope you are doing great.

I am using knime and not getting which node I need to use…

Requirement:
Derive Month, Year , & financial year from following document date:

Document Date:
31-3-2019

Output:
Month: 3
Year : 2019
Financial Year: 2018-19

PS: In India Financial year is consider and not calendar year, where Financial year begins from April and ends in March, therefor here 2018-19.

Thanks in advance.

Ok.
You have to use two “Date time to string” node respectively with yyyy and MM pattern
After you can compute financial year with a simple math formula or a Java snippet node that tests if month is greater than boundary value and build output string.

1 Like

Hi @ravi13,

You can use the String to Date&Time, Extract Date&Time Fields and Date&Time Shift nodes to achieve this. I created a workflow for you: extract_financial_year.knwf (16.5 KB)

Regards,
Simon

3 Likes

Hi!! @SimonS

Thanks for your effort, but in second row I am getting Financial Year as 2019-2019, it should be 2019-2020…

See because,
Financial start from April and ends in March next year.
for example: 01-April-2019 to 31-March-2020 and your date 31-12-2019 will fall here, i.e. 2019-20.

Hope you understand my concern.

Ah, I misunderstood the concept. This can easily be fixed with a Math Formula node, see: extract_financial_year.knwf (18.2 KB)

Cheers

4 Likes

Thansk @SimonS it worked!! :relaxed:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.