Tmap get the last day of the previos month

Highlighted
Five Stars

Tmap get the last day of the previos month

So i have a situation, Where i have to get the last day of the previos month.

Example if  the  present date is september 25 i have to get August 31 .And it has to be in this format YYYY-MM-DD.

 

 


Accepted Solutions
Highlighted
Six Stars

Re: Tmap get the last day of the previos month

This will work

 

TalendDate.getLastDayOfMonth(TalendDate.addDate(TalendDate.getCurrentDate(),-1,"MM") ) 

 

and to get in YYYY-MM-DD format change your port dateformat to yyyy-MM-dd from default format.

 

Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.

View solution in original post


All Replies
Highlighted
Six Stars

Re: Tmap get the last day of the previos month

This will work

 

TalendDate.getLastDayOfMonth(TalendDate.addDate(TalendDate.getCurrentDate(),-1,"MM") ) 

 

and to get in YYYY-MM-DD format change your port dateformat to yyyy-MM-dd from default format.

 

Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.

View solution in original post

Highlighted
Five Stars

Re: Tmap get the last day of the previos month

how can I make it a string

Highlighted
Six Stars

Re: Tmap get the last day of the previos month

To convert to string 

 

FormatterUtils.format_Date(TalendDate.getLastDayOfMonth(TalendDate.addDate(TalendDate.getCurrentDate(),-1,"MM")) , "yyyy-MM-dd").toString() 

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog