Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DB2 SQL Functions?... Need HELP!

Status
Not open for further replies.

grunasal

Programmer
Aug 28, 2000
3
US
Here is my SQL for DB2 AS/400:
----------------------------------------------------
SELECT ARLIB.EDXCTLP.EDATE, ARLIB.EDXCTLP.CTRL#, ARLIB.EDXCTLP.VEND#, ARLIB.EDXCTLP.VNAME, ARLIB.EDXCTLP.ETRANDT, ARLIB.EDXCTLP.ADROP, ARLIB.EDXCTLP.ADC, ARLIB.EDXCTLP.ACPSUB, ARLIB.EDXCTLP.RDROP, ARLIB.EDXCTLP.RDC, ARLIB.EDXCTLP.REJSUB, ARLIB.EDXCTLP.BATTOT, CURDATE()

FROM ARLIB.EDXCTLP

WHERE ETRANDT = CHAR(CURDATE(), mm/dd/yy)
-----------------------------------------------------

My problem is with the WHERE STATEMENT. I'm trying to use the CURDATE() function and the CHAR() function together. What this is essentially doing is taking the CURDATE() function and turning the value into a string. The problem I'm running into is that I need the string in the format mm/dd/yy. CURDATE is putting it in the format mm/dd/yyyy. I only need the two did year. Please help!
 
Why don't you just substring out the information you need. For example, you could format your WHERE clause as such:

WHERE ETRANDT = LEFT(CHAR(CURDATE(), mm/dd/yy),6)||RIGHT( CHAR(CURDATE(), mm/dd/yy),2)

The equality portion of the where clause should translate to the current date in mm/dd/yy format.

Hope that helps!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top