Reformatting date field

More
4 years 5 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
4 years 5 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.

Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Read more
Marketing
Set of techniques which have for object the commercial strategy and in particular the market study.
Google
Accept
Decline
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Google Analytics
Accept
Decline
Functional
Tools used to give you more features when navigating on the website, this can include social sharing.
Advertisement
If you accept, the ads on the page will be adapted to your preferences.
Google Ad
Accept
Decline
Save