Search code examples
sql-serverexportdate-formattalend

Date changes while exporting from sql server to csv using talend


I am exporting data from SQL Server in csv fle using Talend. The date format I specified in tMap component is "YYYY-MM-DD 00:00:00.000". The date in SQL is 2015-04-28 00:00:00.000 which changes to 2015-04-118 00:00:00.000 in csv after export.


Solution

  • Assuming Talend is just using the format patterns of SimpleDateFormat, you want yyyy-MM-dd 00:00:00.000 - the problem you're seeing at the moment is that D means day of year, not day of month. That's why you're getting 118 - because April 28th is day 118 in a non-leap year.

    Around the start and end of the year you'd also see problems because Y means "week-year" rather than year.