Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello!
I have a table in which I have data for month and year.
Table:Fact_1:
Month Year Turnover
10 2019 500
11 2019 1000
Now based on the month and year, I want to have first day of the month to be caculated with date type.
Month Year Date Turnover
10 2019 2019-10-01 00:00:00 500
11 2019 2019-11-01 00:00:00 1000
How can I calculate this date in tmap?
Regards
PV
I'm not sure if you are asking for the first day (as in 01) or the first day name? I'll show both. The first day name can be calculated as below. I'll assume your data row is "row1" and I'll use your column names....
routines.TalendDate.formatDate("EEEE",routines.TalendDate.parseDate("yyyy-MM-dd", row1.Year+"-"+row1.Month+"-01")));
If you want just the date as a numerical String, you don't need to do anything special. Just the below....
row1.Year+"-"+row1.Month+"-01 00:00:00"
If you want to convert it to an actual Date object, do the following....
routines.TalendDate.parseDate("yyyy-MM-dd", row1.Year+"-"+row1.Month+"-01")
I'm not sure if you are asking for the first day (as in 01) or the first day name? I'll show both. The first day name can be calculated as below. I'll assume your data row is "row1" and I'll use your column names....
routines.TalendDate.formatDate("EEEE",routines.TalendDate.parseDate("yyyy-MM-dd", row1.Year+"-"+row1.Month+"-01")));
If you want just the date as a numerical String, you don't need to do anything special. Just the below....
row1.Year+"-"+row1.Month+"-01 00:00:00"
If you want to convert it to an actual Date object, do the following....
routines.TalendDate.parseDate("yyyy-MM-dd", row1.Year+"-"+row1.Month+"-01")