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

Announcements
Learn how to migrate to Qlik Cloud Analytics™: On-Demand Briefing!
cancel
Showing results for 
Search instead for 
Did you mean: 
rp2018
Creator
Creator

How to keep same date format as Database date format?

How do you keep the same date format coming from mssqlinput?  

Sqlserver date is 2018-06-14 11:44:40.320

When mssqlinput passes a date column to tJavaRow the date output is different in the run console.

Result from run console

[statistics] connected
Input Date: Thu Jun 14 11:44:40 CDT 2018

 

Even I tried converting it in tJavaRow and get the same result.

context.run_date = (TalendDate.parseDate("yyyy-MM-dd HH:mm:ss0683p000009M9p6.pngSS",TalendDate.formatDate("yyyy-MM-dd HH:mm:ss0683p000009M9p6.pngSS",row1.InputStart)));

System.out.println("run_date: "+context.run_date);

 

Labels (3)
5 Replies
vapukov
Master II
Master II

if ti only for println, You do not need double conversion, use just formatDate

context.run_date_print = (TalendDate.parseDate("yyyy-MM-dd HH:mm:ss.SS",TalendDate.formatDate("yyyy-MM-dd HH:mm:ss.SS",row4.date_as_date))) ;
context.run_date_print_string = TalendDate.formatDate("yyyy-MM-dd HH:mm:ss.SS",row4.date_as_date) ;

System.out.println("run_date_as_date: "+context.run_date_print);
System.out.println("run_date_as_string: "+context.run_date_print_string);

 

run_date_as_date: Thu Jun 14 11:44:40 NZST 2018
run_date_as_string: 2018-06-14 11:44:40.320
rp2018
Creator
Creator
Author

Thanks this worked.

 

 

 

Anonymous
Not applicable

I think a bigger issue needs tackling here. Dates are NOT stored with formats. They are simply numbers. Your Date format is just how your device makes it human readable to you. When you want to write a date to a String or use a date in a SQL query, you will have to format it because it is being converted to a different class. But if you are simply passing a date as a date class, formats are irrelevant.

vapukov
Master II
Master II

I think - this is not a "issue", this is just proper usage

Anonymous
Not applicable

I think you may have misunderstood what I was getting at @vapukov. The "issue" here is that too many developers seem confused by Dates and expect them to be formatted as part of the object. This misunderstanding leads to lots of questions and confusion over Dates with Talend.