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:
#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)
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.
This actually only worked for an isolated occurrence, and then failed.
I am now using substring to pull out the numbers in the format I need to compare them to.
where OHCSNO = 206576 and integer(substr(OHESDT,1,6)) = '160926'
Thanks!