Skip to main content

HI Team,

 

Please help me to find the week number from given date.
how to use weeknum functions and lookup’s

 

Thanks

Madhavan P

Hi @Madhavan P Not sure of the exact use-case but did you check out for the JDBC lookup processor. 

https://docs.streamsets.com/portal/datacollector/latest/help/datacollector/UserGuide/Processors/JDBCLookup.html#concept_ysc_ccy_hw

Also, depending upon which DB you are using. You might want to use function like DATE_PART() to retrieve the week number from a date.

 


@Madhavan P 

If you are using SQL then you can try with below query.

select datepart(week,'11-july-2020')

 

If you have specific use cases then you can provide the details to get the resolution for the same.

 

Thanks & Regards

Bikram_


Thanks Bikram.

I am using the source(origin) as api and below is sample response.

        {
            "resolved_at": "2022-10-25 22:19:05",
            "sys_created_on": "2022-10-25 18:02:04",
            "caller_id": "Event Integration",
            "category": "EVENT GENERATED",
            "u_casual_ci": "DDL Hadoop"
        },
        {
            "resolved_at": "2022-10-26 15:05:41",
            "sys_created_on": "2022-10-26 11:40:08",
            "caller_id": "Event Integration",
            "category": "EVENT GENERATED",
            "u_casual_ci": "DDL Hadoop"
        }

 

From this I have to add the additional columns (week number and month number from the sys_created_on).

 

Thanks

Madhavan P


@Madhavan P there is no out of the box weeknum function in StreamSets expression language but you can use an evaluator like Groovy to get the weeknum. Be careful as week number can be different depending upon the locale. So for North America it is +1 compared to Italy. 

 

Some sample code here: https://www.baeldung.com/java-get-week-number


@Madhavan P 

Please find attached the pipeline for the week number from the date string.

As part of testing i consider one date field , you can follow the same code for others if you need the week number for other date fields.

Kindly let me k now if it helps in your case.

 

Thanks & Regards

Bikram_


Reply