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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] DateDiff troubles

Hi,
I try to use Talend.DateDiff but I don't understand the return value:
I use a TjavaRow to print the number of days between a date and current date.
Date_contractuelle_de_remise_du_document is coming from a excel spreadsheet and is french formatted 'dd/MM/yyyy'
System.out.println(TalendDate.parseDate("dd/MM/yyyy",input_row.Date_contractuelle_de_remise_du_document)+ " "
+ TalendDate.getCurrentDate() + " " + TalendDate.diffDate(TalendDate.getCurrentDate(),TalendDate.parseDate("dd/MM/yyyy",input_row.Date_contractuelle_de_remise_du_document),"dd"));
Result from execution is :
Sat Jan 10 00:02:00 CET 11 Tue Oct 18 14:49:24 CEST 2011 730768
Sat Jan 10 00:02:00 CET 11 Tue Oct 18 14:49:24 CEST 2011 730768
Sat Jan 10 00:02:00 CET 11 Tue Oct 18 14:49:24 CEST 2011 730768
Sat Jan 10 00:02:00 CET 11 Tue Oct 18 14:49:24 CEST 2011 730768
Tue Jan 13 00:06:00 CET 11 Tue Oct 18 14:49:24 CEST 2011 730765
Why do I get 730765 days between 13th of January and 18th of october ?
Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

I found a solution, but not really an explanation !
If I parse using "dd/MM/yy", il works. So even if I parse the excel string cell in "dd/MM/yyyy", I think I get dd/MM/00yy. So the difference of 730xxx days comes from that silly interpretation of a string from excel in dd/MM/yyyy format.

View solution in original post

4 Replies
Anonymous
Not applicable
Author

Hi miniquick
Try the following Code:
System.out.println(TalendDate.parseDate("dd/MM/yyyy",input_row.Date_contractuelle_de_remise_du_document)+ " " 
+ TalendDate.getDate("dd/MM/yyyy") + " " + TalendDate.diffDate(TalendDate.parseDate("dd/MM/yyyy",TalendDate.getDate("dd/MM/yyyy")),TalendDate.parseDate("dd/MM/yyyy",input_row.Date_contractuelle_de_remise_du_document),"dd"));

Regards
Brandon
Anonymous
Not applicable
Author

Thanks for truying to help me, but I got the same result.
Anonymous
Not applicable
Author

Hi
It seems like like the locale is taken wrongly in your time CET and CEST.
Anonymous
Not applicable
Author

I found a solution, but not really an explanation !
If I parse using "dd/MM/yy", il works. So even if I parse the excel string cell in "dd/MM/yyyy", I think I get dd/MM/00yy. So the difference of 730xxx days comes from that silly interpretation of a string from excel in dd/MM/yyyy format.