Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
nivedhitha
Creator III
Creator III

Date conversion in tDbRow component

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 0683p000009M3XB.png

 

converting the date field into string in tmap like this 0683p000009M3XL.png

 

And then in my tDbRow I have used CAST to change it to DateTimeValue like this0683p000009M3XV.png

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?

 

Labels (2)
1 Solution

Accepted Solutions
nivedhitha
Creator III
Creator III
Author

Hi @nthampi ,

 

thanks for your response.

I just fixed it using the below formula.

CONVERT(datetime,\'"+((String)globalMap.get("row3.Execution_End_Ts"))+"\')

 

 

 

 

View solution in original post

2 Replies
Anonymous
Not applicable

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 🙂

nivedhitha
Creator III
Creator III
Author

Hi @nthampi ,

 

thanks for your response.

I just fixed it using the below formula.

CONVERT(datetime,\'"+((String)globalMap.get("row3.Execution_End_Ts"))+"\')