Hi all,
I have searched a great deal for a solution but can't find my exactly what I need, or at least I can't put it all together.
First I need to retrieve a stored date from my AS400 and return it in a date format of mm/dd/yyyy or mm/dd/yy.
All date fields have a corresponding numeric 7,0 field and numeric 6,0 field. YYYYDDD and MDDYY respectively.
Example of a date field named NPTD7 would appear as 2011006 or 2/1/2011 as 2011032.
If it is simpler I could work with the other version, NPTD6 in this sample, so 2/1/2011 would appear as 20211 (note that if the month is only 1 digit, it does not include the zero but drops it which throws me a curve when I try and use something like:
date(SUBSTRING(CAST(NPDT6 AS VARCHAR(6)),1,2)concat'/'concat
SUBSTRING(CAST(NPDT6 AS VARCHAR(6)),3,2)concat'/'concat
SUBSTRING(CAST(NPDT6 AS VARCHAR(6)),5,2)) AS MyDate
What SQL can I use to convert either of these?
Second question is I then need to build a query to retrieve all records where NPTD7 are >= curdate() and return the NPTD7 as a mm/dd/yyyy or mm/dd/yy value.
Thanks kindly.
I have searched a great deal for a solution but can't find my exactly what I need, or at least I can't put it all together.
First I need to retrieve a stored date from my AS400 and return it in a date format of mm/dd/yyyy or mm/dd/yy.
All date fields have a corresponding numeric 7,0 field and numeric 6,0 field. YYYYDDD and MDDYY respectively.
Example of a date field named NPTD7 would appear as 2011006 or 2/1/2011 as 2011032.
If it is simpler I could work with the other version, NPTD6 in this sample, so 2/1/2011 would appear as 20211 (note that if the month is only 1 digit, it does not include the zero but drops it which throws me a curve when I try and use something like:
date(SUBSTRING(CAST(NPDT6 AS VARCHAR(6)),1,2)concat'/'concat
SUBSTRING(CAST(NPDT6 AS VARCHAR(6)),3,2)concat'/'concat
SUBSTRING(CAST(NPDT6 AS VARCHAR(6)),5,2)) AS MyDate
What SQL can I use to convert either of these?
Second question is I then need to build a query to retrieve all records where NPTD7 are >= curdate() and return the NPTD7 as a mm/dd/yyyy or mm/dd/yy value.
Thanks kindly.