Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
anna_talend
Contributor
Contributor

put the current date into a postgresql timestamp column

Hi,
I'm new with talend and can't find a solution for the following simple problem:
I want to write the current date to a postgressql column with type "timestamp without timezone" using the components tMap and tPostgreSQL.
I tried TalendDate.getDate("CCYY-MM-DD hh:mm:ss") the talend format is Date with dateformat "yyyy-MM-dd' 'HH:mm:ss"
If I try to run the job it complains Talend can't convert String to Date
If I change Date to String, the job starts but cannot write the data to the database I get the errormessage "ERROR: column »datum_anlage« has type timestamp without time zone, but the expression has Typ character.
Has anybody an idea how to solve this problem?
Thanks!
anna.talend
Labels (2)
3 Replies
Anonymous
Not applicable

Open Studio doesn't shield you from the underlying Java language very much at all. Java is strongly typed, and you'll come across this type of thing again and again as you get familiar with Talend.
So, since what you're writing to is a Date, you have to send a java Date object. And the schema has to be set to Date. You can create a java date with the java expression "new Date()", or if that doesn't work "new java.util.Date()". That will be the current time.
So, instead of "TalendDate.getDate()", try "new java.util.Date()" and let us know if that gives a different error message (sorry it's not convenient for me to create a new job and table to test it out but I think that'll work).
Levin
anna_talend
Contributor
Contributor
Author

Hi Levin,
thanks, a lot!
I tried java.util.Date and java.sql.Timestamp both works.
anna.talend
bhagyarekha
Creator II
Creator II

Hi,
The question is very old,but when am trying to do the same am unable to get the out put
am using tmap and tmysql output
and only one column date and in tmap date column  expression i am using "new java.util.Date()".but it is not displaying nor inserting date column into table
tmap---->tmysqloutput
regards,
rekha