- Posts: 4
- Thank you received: 0
Reformatting date field
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]
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.
1 year 7 months ago #21584
by admin
Mike
ETL Architect
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;
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.