Reformatting date field

More
1 year 7 months ago #21583 by Hart
Reformatting date field was created by Hart
Hello

I am receiving files from the customer with the inconsistent format of date fields

most of the time it is yyyy-mm-dd
But sometimes it is yyyy/mm/dd

I am trying to use the following calculations to correct the issue but it does not work.

IF SubString([INVOICE DATE],3,1)='/' then Result := RightString([INVOICE DATE],4)+'-'+SubString([INVOICE DATE],4,2)+'-'+LeftString([INVOICE DATE],2) else Result : =[INVOICE DATE]

Please Log in or Create an account to join the conversation.

More
1 year 7 months ago #21584 by admin
Replied by admin on topic Reformatting date field
This one works

begin
if SubString([INVOICE DATE],3,1)='/' then
Result := RightString([INVOICE DATE],4)+'-'+SubString([INVOICE DATE],4,2)+'-'+LeftString([INVOICE DATE],2)
else
Result :=[INVOICE DATE];
end;

Mike
ETL Architect

Please Log in or Create an account to join the conversation.