GetDates ( )

Function stats

Average user rating
37
95
9999
Support
FileMaker 8.0 +
Date posted
05 December 2008
Last updated
15 May 2009
Version
Recursive function
Yes

Author Info
 Fabrice

74 functions

Average Rating 4.4

author_avatar



 

Function overview

Prototype

GetDates  ( _text )


Parameters

_text  


Description

Tags:  Text Parsing   Date  

Extracts all valid dates from a text and formats them as a list

Examples

Sample input

a text with dates in it


Sample output

a list of dates

 

Function code

/* GetDates ( _text )
by Fabrice Nordmann

v1, Mar 2007

Extracts all valid dates from a text and formats them as a list
*/


Let ([
$$text = Case ( IsEmpty ( $$text ) ; Substitute ( _text ; [ "." ; "/" ] ; [ "-" ; "/" ] ) ; $$text )
; _adjText = Substitute ( Filter ( _text ; "0123456789 /-." )
; [ "-" ; "/" ]
; ["." ; "/"]
)
; _date = LeftWords ( _adjText ; 1 )
; _date = Case ( IsValid ( GetAsDate ( _date )) and PatternCount ( _date ; "/" ) = 2 and PatternCount ( $$text ; _date ) ; GetAsDate ( _date ) ; "" )
; $$parseDates = $$parseDates & Case ( not IsEmpty ( $$parseDates ) and not IsEmpty ( _date ) ; ¶ ) & Case ( not IsEmpty ( _date ) ; _date )
];
Case ( not IsEmpty ( _text )
; GetDates ( RightWords ( _adjtext ; WordCount ( _adjtext ) - 1 ))
; $$parseDates &
Let ([
$$parseDatesResult = $$parseDates
; $$parseDates = ""
; $$text = ""
];
"" )
))

// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/95

    Prototype: GetDates( _text )
    Function Author: Fabrice (http://www.fmfunctions.com/mid/37)
    Last updated: 15 May 2009
    Version: 1.1

*/
// ===================================

 

 

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (31)
Date  (28)
XML  (26)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Interface  (15)
Layout  (15)
Text  (14)
Variables  (12)
Layout Objects  (11)
Filter  (11)
Design  (10)
Array  (7)