Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: gmullinIn your case you might have a date that has 10/1/2017 which would need to be converted using "MM/D/CCYY" and then you could have 9/1/2017 which would use "M/D/CCYY". You will have to use the function isDate() to check the format before doing the conversion. What version of LAE are you on? You might have the accelerators library, it has a node called Date Conversion that will cycle through all the different types and convert for you. Or you can write your own BRAINScript in a filter node. I think this will cover you, if I missed one format just add it to the if statement in the filter.
node:Dates
bretype:core::Static Data
editor:Label=Dates
editor:sortkey=59fc5f3a236836b4
output:@40fe6c55598828e5/=
prop:StaticData=<<EOX
DateField
9/1/2017 00:00:00
10/1/2017 12:00:05
8/30/2016 13:00:00
EOX
editor:XY=180,280
end:Dates
node:Filter
bretype:core::Filter
editor:sortkey=59fc5f6a645d7b9c
input:@40fd2c74167f1ca2/=Dates.40fe6c55598828e5
output:@40fd2c7420761db6/=
prop:Script=<<EOX
_date = 'DateField'
# check format before trying to convert to date
if _date.isDate("MM/DD/CCYY") then
_newdate = _date.str().date("MM/DD/CCYY")
else if _date.isDate("M/D/CCYY") then
_newdate = _date.date("M/D/CCYY")
else if _date.isDate("MM/D/CCYY") then
_newdate = _date.date("MM/D/CCYY")
else if _date.isDate("DD/M/CCYY") then
_newdate = _date.date("DD/M/CCYY")
else
_newdate = date(null)
emit _newdate as "Date_Format", 'DateField' as "Date_Original", _date as "Date_String"
EOX
editor:XY=320,280
end:Filter