Excel and Date

More
2 years 6 months ago - 2 years 6 months ago #23084 by bruce.gibbins
Excel and Date was created by bruce.gibbins
Hi

have an excel file coming in with a row with a date formatted as DD-MMM. AETL is reading this as a String and not returning the underlying value.

For example it displays as 31-DEC in the workbook and 31-DEC in the AETL transformation designer. We need to format this as a real date and so Reformat Date Transforantion action was used with the expectation that it would take the underlying value and return a date as YYYY-MM-DD

However, because it read it as a string it appended the current year onto the string making 31-DEC-2024 where the correct value should have been 31-DEC-2023

Also, have tried "Ignore Format Option" on the reader and this displays the underlying numeric value for the date. Would need to then get this into YYYY-MM-DD format for SQL.

Any way around this?

Thanks
Last edit: 2 years 6 months ago by bruce.gibbins.

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

More
2 years 6 months ago - 2 years 6 months ago #23086 by admin
Replied by admin on topic Excel and Date
Excel stores dates as sequential serial numbers so that they can be used in calculations. By default, January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,447 days after January 1, 1900.

The easiest way to address this problem is to use calculation transformation function

The following script will convert the number to date
Code:
var d: TDateTime; begin; d:=StrToInt([F001]); Result:=d; end;






Mike
ETL Architect
Last edit: 2 years 6 months ago by admin.
The following user(s) said Thank You: bruce.gibbins

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

More
2 years 6 months ago #23088 by bruce.gibbins
Replied by bruce.gibbins on topic Excel and Date
Thanks for this and I can verify it has resolved our issue. My only comment would be that whilst I had considered a script solution and understand serial dates, I would not have immediately considered the StrToInt() function as it isn't (to me) intuitively related to date manipulation. I can see that a new article on this topic has been added. Thanks again.

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