KB-33740: Converting Storage’s E3 TimeStamp field into DateTime.

Question:

Can I create a query converting the E3TimeStamp field from the E3Storage‘s table into DateTime?

Solution:

Yes, you can do this.

If you are using Oracle, you must use E3GetDateValue function, created automatically by E3. This function converts a number into a date. To visualize on the date/time format, also use TO_CHAR function.

Example:

Query.SQL = "SELECT TO_CHAR(E3GETDATEVALUE(E3TimeStamp),'DD/MM/YYYY HH:MI:SS')AS E3TimeStamp ,
FieldValue FROM <%TableName%> WHERE ( E3TimeStamp  >= <%StartTime%>  AND   E3TimeStamp <= <%EndTime%>
AND FieldID = <%Fid%> ) ORDER BY E3TimeStamp"

To display date/time with the accuracy of milliseconds, add SSSSSS to the date format in the TO_CHAR command.

Example:

SELECT TO_CHAR(E3GETDATEVALUE(E3TimeStamp),’DD-MM-YYYY HH:MI:SS.SSSSS’)AS E3TimeStamp
FROM <%TableName%>

Note: To create a filter by date, fill in <%StartTime%> and <%EndTime%> variables with date/time in Float or Double format. Use CDbl() function from the VBScript to convert a date into Double.

If you are using SQL, use  CONVERT command: CONVERT ( data_type [ ( length ) ] , expression [ , style ] ).

Example:

Query.SQL = "SELECT FieldID,Convert(datetime,E3TimeStamp -2) AS E3TimeStamp,FieldValue FROM
 <%TableName%> WHERE ( E3TimeStamp  >= <%StartTime%>  AND   E3TimeStamp <= <%EndTime%> AND
 FieldID = <%Fid%> ) ORDER BY E3TimeStamp"

Note: You must write “E3TimeStamp -2” in this case, because there is a difference between Elipse E3’s and SQL’s default calendars. The default date used by E3 is 30/12/1899 0:00:00; SQL, on the other hand, uses 01/01/1900 0:00:00. When recording the information in the database, E3 will use its default date; SQL, however, will use own date when converting.

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *