Hi, I'm new to the world of AS/400, most of my backgroud has been SQL Server with some Oracle thrown in there. I'm having problems trying to use the LEFT function in a query.
I have a column that is storing a date value as a number, for example today's date 05/14/2004 is stored in the format of 20040514 (yyyymmdd). Now, if I want to run a query on a specific date, (Where Date = 20040514) everything works great. But I need to pull all records for a certain month. Since I have a numeric datatype, I can't run any type of Month or Date functions, so I decided to just take the left six numbers (yyyymm) and use those.
Here's my query:
This is the error I get:
Argument 1 of function LEFT not valid.
I tried putting single quotes around 'I.TDATE' but that just passes the value as a literal. I don't get errors but the query doesn't return results.
Since I know very little about the AS/400, I was wondering if someone could tell me if have some syntax problems in my query, or if theres a better way to accomplish what I'm trying to do.
Thanks!
Hope This Helps!
Ecobb
"My work is a game, a very serious game." - M.C. Escher
I have a column that is storing a date value as a number, for example today's date 05/14/2004 is stored in the format of 20040514 (yyyymmdd). Now, if I want to run a query on a specific date, (Where Date = 20040514) everything works great. But I need to pull all records for a certain month. Since I have a numeric datatype, I can't run any type of Month or Date functions, so I decided to just take the left six numbers (yyyymm) and use those.
Here's my query:
Code:
SELECT DISTINCT I.TLOCCD AS Location
FROM ARLIB.INVTRAN I
INNER JOIN ARLIB.PRODBASE P ON P.BROD = I.TITEM
[red]WHERE LEFT(I.TDATE, 6) = 200405[/red]
AND P.BWGT > 0
Argument 1 of function LEFT not valid.
I tried putting single quotes around 'I.TDATE' but that just passes the value as a literal. I don't get errors but the query doesn't return results.
Since I know very little about the AS/400, I was wondering if someone could tell me if have some syntax problems in my query, or if theres a better way to accomplish what I'm trying to do.
Thanks!
Hope This Helps!
Ecobb
"My work is a game, a very serious game." - M.C. Escher