Data Conversion using pyodbc to query iSeries database - Conversion error
<p>I am trying to filter records based on a Zoned Decimal value that is returning as Decimal(160919, ).  How can I use this to filter against a date (ie: 160919)
Below is the code that I'm using to extract the order data:</p>

<pre><code>#connect to APlus
import pyodbc
import time
import cursor as cursor


today = int(time.strftime("%y%m%d"))
whatisit = type(today)
print whatisit
cnxn = pyodbc.connect('DSN=aplus; uid=username;pwd=password')
cursor = cnxn.cursor()
query = """ select OHORNO, OHRSDT
            from ORHED
            where OHCSNO = 206576  and CAST(OHRSDT AS INT) = '$[today]'"""
cursor.execute(query)
row = cursor.fetchall()
if row :
    print(row)

print ("Today : " + today)
</code></pre>

<p>There ended up being a space at the end of the date in the record.  I used Left(OHEXDT, 6) to compare and everything is working as expected. </p>

<p>This actually only worked for an isolated occurrence, and then failed. </p>

<p>I am now using substring to pull out the numbers in the format I need to compare them to.  </p>

<p><code>where OHCSNO = 206576 and integer(substr(OHESDT,1,6)) = '160926'</code></p>

<p>Thanks!</p>

python sql ibm-midrange pyodbc db2400