Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
can anyone explain use of alt() function with example
The alt function returns the first of the parameters that has a valid number representation. If no such match is found, the last parameter will be returned. Any number of parameters can be used.
Example:
alt( date#( dat , 'YYYY/MM/DD' ),
date#( dat , 'MM/DD/YYYY' ),
date#( dat , 'MM/DD/YY' ),
'No valid date' )
Will test if the field date contains a date according to any of the three specified date formats. If so, it will return the original string and a valid number representation of a date. If no match is found, the text 'No valid date' will be returned (without any valid number representation).
Hi,
If you have mixed date format in one field or you have data from different sources using
different formats, you can use the Alt() function to define several possible date formats:
Alt( Timestamp#(MixDate,'M/D/YYYY h:mm tt'),
Date#(MixDate,'M/D/YYYY'),
Date#(MixDate,'D/M/YYYY'),
Date#(MixDate,'YYYYMMDD'),
Date#(MixDate,'DD.MM.YYYY'),
Date#(MixDate'YYYY-MM-DD')
) as MixDate
The order of the interpretation functions also defines the priority when several formats are
possible for one specific field value, e.g. 8/4/2012, which in the United States means 4th of
August, but in the United Kingdom means 8th of April.