I have been working on this for several days and tried all the options I could find. I am hoping that someone can clear this up. Within a stored proceedure I am pulling data from JDE into a SQL table. One of the fields is a JDE date field and I need this to go into a SQL table in the datetime format. The date field is IVEFTJ.
I have the follwoing:
SELECT DISTINCT * FROM OPENQUERY(GDCJDE9PRODR, '
SELECT
IVLITM,
IVCITM,
IVEFTJ,
Convert(datetime,DATEADD(day,[IVEFTJ]-729960,Convert(datetime,"1900-01-01")),103) as BCDAte
FROM
PRODDTA.F4104
WHERE
IVXRT = ''UP''
')
You can’t use the SQL functions inside the openquery SQL statement, as this statement is relevant to the database you are selecting rows from. Rather, use the functions in the outer SQL statement, like this:
Here is sqlfiddle for you to play with