I'm having a bit of trouble working with dates and the AS400. I'm writing a program with PHP that will allow users to see a customer requirements schedule based on different selections such as price, qty, labor, etc... Part of this program uses the week number (since users will select their date range based on weeks)
My issue is this the current date format in field I'm using is 20100114 or YYYYMMDD which is stored as a numeric value and from this I would like to pull what week of the year it is.
If I simply try using WEEK($DATA) where the $data is my actual column name, it won't work. The only way I've gotten this to work is by using the strsql command on the AS400 itself and converting the date with the following command:
WEEK(DATE(CONCAT(CONCAT(CONCAT(CONCAT(SUBSTR(DIGITS(LSDTE),5,2),'/'),SUBSTR(DIGITS(LSDTE),7,2)),'/'),SUBSTR(DIGITS(LSDTE),3,2))))(the reason for so many concatenations is I can't concat more than 2 items at a time because of whatever reason on the AS400)
However when I try to do this with the ODBC connection in PHP it simply laughs at me.
This is the SQL I'm using in the PHP script that I'm simply testing with:
$SQL = "select LPROD, LQORD, LQSHP, LSDTE, WEEK(DATE(CONCAT(CONCAT(CONCAT(CONCAT(SUBSTR(DIGITS(LSDTE),5,2),'/'),SUBSTR(DIGITS(LSDTE),7,2)),'/'),SUBSTR(DIGITS(LSDTE),3,2))))
FROM BPCS405CDF.ECL
where LID = 'CL' and LPROD = 'D61120104GAT'"; This query returns all the values except the week number even though it returns the value on the AS400.
So the answers I'm looking for are:
- When you use a ODBC connection what is the SQL based on? In this case the AS400 or PHP's ODBC stuff?
- If it is the AS400 any ideas why this won't work?Or evne a possible alternate solution
An alternate solution I can think of is creating a table that simply has the date and the conversation date along with the week and week day. However that is not a very reliable way and I would not like to do that if possible.