Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to find first and last day of a year

hi

 

i need to find first and last day of an year 

 

 

for exmaple : in the year is 2019 in need first day as 01-01-2019 and last day as 31-12-2019

 

Labels (4)
2 Replies
Jaggu1992
Contributor
Contributor

Hi,

 

 

Can you provide some sample data.

 

 

Thanks,

Jagan.

Anonymous
Not applicable
Author

Get the year number of a Date using built-in function TalendDate.getPartOfDate("YEAR", Date date), eg:
TalendDate.getPartOfDate("YEAR", row1.columName), and then you are able to get the first day and the last day of a year with string value.
first day: "01-01-"+TalendDate.getPartOfDate("YEAR", row1.columName)
last day: "31-12-"+TalendDate.getPartOfDate("YEAR", row1.columName)

If you need to convert the string value to a Date, using this expression:
TalendDate.parseDate("dd-MM-yyyy","31-12-"+TalendDate.getPartOfDate("YEAR", row1.columName))

Hope it helps you!

Regards
Shong