Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
EvoticTalend
Contributor
Contributor

getCurrentYear in a tMap

Hi everyone

I have a tMap with:

"01/"+row1.month

as VAR1 in the middle, and then is passed to the output

TalendDate.parseDate("dd/MM", Var.VAR1 )

I have days and months but I need THE CURRENT YEAR. ¿ What would be the best option? 

Thank you.

Labels (3)
11 Replies
gjeremy1617088143

Hi,

TalendDate.parseDate("dd/MM/YYYY",Var.VAR1 +"/"+ TalendDate.formatDate("YYYY",TalendDate.getCurrentDate()

))

Send me Love and Kudos

 

 

EvoticTalend
Contributor
Contributor
Author

Hi!

 

I tried this code and Idk why Im having another month:

 

Column month are the months of my table, column Date is your code

 

0695b00000Gg7EmAAJ.png

gjeremy1617088143

Hi,

I saw month is only on one character :

so in var1 you can replace row1.month by : String.format("%02d",Integer.valueOf(row1.month))

it will add a zero on the left if month is only on one character.

Send Me love and Kudos

EvoticTalend
Contributor
Contributor
Author

Hi again!

 

I fixed the day and month variable as "01/"+ String.format("%02d",Integer.valueOf(row1.month)) 

And in the output I put your code as in the first response.

 

 

 

BUT I still have the same problem, the mont is other, so strange...

The first column is only the day and month (with the zero)

The second column is your code.

 

 

0695b00000Gg7Q9AAJ.png 

 

gjeremy1617088143

Could you send the date pattern of the date output schema ?

 I think you have to set the date pattern in your output schema as :

"dd/MM/YYYY"

EvoticTalend
Contributor
Contributor
Author

This is the pattern in the output:

0695b00000Gg7UzAAJ.png 

I created a var2 with only the year

0695b00000Gg7VJAAZ.png 

And then in the output I have var1 + var2

0695b00000Gg7VTAAZ.png 

But in the DDBB I still have the data with another month and the format isn't the correct despite being put the format with "/" and year at final

 

0695b00000Gg7VdAAJ.png

gjeremy1617088143

Hi, if ou put a tlogrow after the tmap , wich value do you have?

You try to send it in a database ,if yes in wich database (sql server ,postgre, mysql...)?

the pattern seems to be :

"YYYY-MM-DD hh:mm:ss.SSS"

gjeremy1617088143

so maybe try :

Var.VAR1 = String.format("%02d",Integer.valueOf(row1.month)) +"-01"

output : Var.VAR2 + "-"+Var.VAR1

pattern of output : "YYYY-MM-DD"

and maybe on your database server don't have the same utc date, it can cause different date if you have some hour of shift.

EvoticTalend
Contributor
Contributor
Author

Yes, im trying to send this to a DDBB, SQL SERVER. I put the pattern as "dd/MM/YYYY" but still in YYYY-MM-DD