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

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
imholzj
Contributor III
Contributor III

How to check date strings, where the leading month has either 1 or 2 digits?

isDate("4/10/2018", "MM/dd/yyyy") returns false

 

I'm trying to filter on a string field that is supposed to be a date, so I want to check first with TalendDate.isDate in a filter.

 

jji

 

I guess the real question is why does:

String foo = "4/13/2001";
String format = "MM/dd/yyyy";
System.out.println( TalendDate.isDate( foo, format ) );
System.out.println( TalendDate.compareDate( new Date(), TalendDate.parseDate( format, foo ) ) );

 

return:

false
1

Labels (2)
1 Solution

Accepted Solutions
DataTeam1
Creator
Creator

You can use

TalendDate.isDate("4/1/2018", "M/d/yyyy")  returns True

 

TalendDate.isDate("12/21/2018", "M/d/yyyy") returns True

 

TalendDate.isDate("15/21/2018", "M/d/yyyy") returns false

View solution in original post

1 Reply
DataTeam1
Creator
Creator

You can use

TalendDate.isDate("4/1/2018", "M/d/yyyy")  returns True

 

TalendDate.isDate("12/21/2018", "M/d/yyyy") returns True

 

TalendDate.isDate("15/21/2018", "M/d/yyyy") returns false