Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone I have an issue:
I have a table called orders and there's a column called "order_date" in datetime format.
Now I need a query which will select always the date range from last Monday 00:00:01 to last Saturday 23:59:59.
How I can build this query and which elements do I need? tMap only?
Thanks for any advice.
Hi,
You can implement by importing corresponding java Library to Talend code using tLibraray code and run the below code in the link.
https://stackoverflow.com/questions/12783102/how-to-get-the-last-sunday-before-current-date
Warm Regards,
Nikhil Thampi
Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Hi,
I have written a simple java code in tjava component which always fetches the date of last Monday and Saturday. This can be assigned to context variables and can be used in where condition while fetching data. But make sure to typecast it to just date (without timestamp) on both sides of where condition. So that no records will be missed due to difference in timestamp.
int num_days = TalendDate.getPartOfDate("DAY_OF_WEEK",TalendDate.getCurrentDate());
System.out.println(TalendDate.addDate(TalendDate.getCurrentDate(),-num_days-5,"dd")); // Last Monday date
System.out.println(TalendDate.addDate(TalendDate.getCurrentDate(),-num_days,"dd")); // Last Saturday date
Regards,
Pratheek Manjunath