Skip to main content

I have a date field in my excel document which I am reading into FME that contains a mixture of dd/mm/yyyy and dd/mm/yy. Unfortunately, some of the fields just have the year, e.g. 1951. with no date or month.

What I'm trying to figure out is how to find just those features that have a year in the date field and then return only those to the inspector.

I looked at AttributeValidator but I see it does not have Date as a Rule configuration under Type.

Hi @rclarkenz, I think that it's a quick way to use the Tester (Contains Regex operator) to determine if the attribute value has just four characters. There should be several ways other than that.

0684Q00000ArJjQQAV.png

Right Value (regular expression that matches a string consisting of just four characters)

^....$

Hi @rclarkenz, I think that it's a quick way to use the Tester (Contains Regex operator) to determine if the attribute value has just four characters. There should be several ways other than that.

0684Q00000ArJjQQAV.png

Right Value (regular expression that matches a string consisting of just four characters)

^....$
Thanks @takashi. I ended up also checking the length of the string in a Tester. If the string was 5 or less, then it mustn't be a correctly formatted date.  

 


To genuinely check if a date is valid, i.e. to reject a date such as 31/02/2017 requires some python.

Probably not required for you if the requirement is only to identify cases with only a year value populated.


To genuinely check if a date is valid, i.e. to reject a date such as 31/02/2017 requires some python.

 Probably not required for you if the requirement is only to identify cases with only a year value populated.

Hi @egomm, in FME 2017.0+, Python scripting is not essential.

 

Tips:

 

In FME 2017.0+, the @DateTimeParse function can be used to determine if a date/time value is valid or not.

 

@DateTimeParse(28/02/2017,%d/%m/%Y) returns "20170228"
@DateTimeParse(31/02/2017,%d/%m/%Y) returns <null>
@DateTimeParse(31/02/2017,%d/%m/%Y,repair) returns "20170303"
In FME 2017.1+, the DateTimeConverter can also be used to filter features based on the date/time validation result. That is, the transformer rejects the input feature if a specified date/time attribute value is invalid, by default  (Repair Overflow: No).

 


Hi @egomm, in FME 2017.0+, Python scripting is not essential.

 

Tips:

 

In FME 2017.0+, the @DateTimeParse function can be used to determine if a date/time value is valid or not.

 

@DateTimeParse(28/02/2017,%d/%m/%Y) returns "20170228"
@DateTimeParse(31/02/2017,%d/%m/%Y) returns <null>
@DateTimeParse(31/02/2017,%d/%m/%Y,repair) returns "20170303"
In FME 2017.1+, the DateTimeConverter can also be used to filter features based on the date/time validation result. That is, the transformer rejects the input feature if a specified date/time attribute value is invalid, by default  (Repair Overflow: No).

 

I will look forward to using that functionality, probably sometime mid 2018 :-)

 

 


Reply