Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Everyone,
I have been having trouble trying to convert a string field to DateTime in tDBRow and insert it into db.
I have a date field from tDBInput that im converting to string in tap and im passing to tFlowToIterate and passing it to tDBRow.
I have to convert this to DateTime of format yyyy-MM-dd HH:mm:ss and insert into SQL Server db.
The job I've designed is
converting the date field into string in tmap like this
And then in my tDbRow I have used CAST to change it to DateTimeValue like this
I don't receive any error but the date is not getting inserted.
I'm committing the inserts, so just not sure what is going wrong here
Can someone please help me with this?
Hi @nthampi ,
thanks for your response.
I just fixed it using the below formula.
CONVERT(datetime,\'"+((String)globalMap.get("row3.Execution_End_Ts"))+"\')
Hi,
It seems you are not giving the format of the string while generating the insert statement inside tDBRow component.
Could you please refer the below link where the query is similar i.e., to insert to DB in a non standard date format.
https://stackoverflow.com/questions/12957635/sql-query-to-insert-datetime-in-sql-server
https://stackoverflow.com/questions/44240160/how-to-insert-datetime-like-this-format-dd-mm-yyyy
Warm Regards,
Nikhil Thampi
Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Hi @nthampi ,
thanks for your response.
I just fixed it using the below formula.
CONVERT(datetime,\'"+((String)globalMap.get("row3.Execution_End_Ts"))+"\')