I am reading an old style order header database (OH) that has an entry date (OHENTD) in numeric MMDDYY format. When using embedded SQL I want to convert that date to a date field on the SELECT statement and then condition it in the WHERE clause for a from/to date. I've never done this before and am having trouble finding out how to do it. This is what I have:
================================================
exec sql declare ohcsr cursor for
select date(timestamp_format(digits(ohentd),'MMDDYY')) as new_date,
ohord#
from oh
where ohotyp in ('SI', 'IO') and
new_date between :from_date and :to_date;
================================================
It does not like the "new_date" in the WHERE clause. Is that considered a host variable and needs the colon in front? Any help is appreciated!!!
================================================
exec sql declare ohcsr cursor for
select date(timestamp_format(digits(ohentd),'MMDDYY')) as new_date,
ohord#
from oh
where ohotyp in ('SI', 'IO') and
new_date between :from_date and :to_date;
================================================
It does not like the "new_date" in the WHERE clause. Is that considered a host variable and needs the colon in front? Any help is appreciated!!!
Comment