I have this query:
SELECT Field1, OrderFor, Writeback, Actshipdate, Orderstatus, receivedate, receivetime
FROM orderinfo, shippinginfo
WHERE orderinfo.orderid = shippinginfo.orderid
AND shippinginfo.custid = '37782'
AND receivedate = DATE(NOW())
AND receivetime = ???????
I am using Sybase adaptive server anywhere and trying to get records for the last hour.
Here is the SQL to show latest time using now() function. Here is the SQL to get last 1 hour data in MySQL. In the above query, we select only those rows whose order_date falls within past 1 hour interval. We use INTERVAL clause to easily substract 1 hour interval from present time obtained using now() function.
It seems that Time is a TEXT field. You should consider to combine Date and Time to get a DateTime field, and then use it in the WHERE clause. Show activity on this post. alter table report add datetimecol as (CAST(date as datetime) + time); create index idx_report_datetimecol on report(datetimecol);
You better make it "order_date >= DateAdd(DAY, -1, GETDATE())" thats it!
try this !!
SELECT Field1, OrderFor, Writeback, Actshipdate, Orderstatus, receivedate, receivetime
FROM orderinfo, shippinginfo
WHERE orderinfo.orderid = shippinginfo.orderid
AND shippinginfo.custid = '37782'
AND receivedate = DATE(NOW())
AND receivetime > DATEADD(HOUR, -1, GETDATE())
Try below query:
SELECT Field1, OrderFor, Writeback, Actshipdate, Orderstatus, receivedate, receivetime
FROM orderinfo, shippinginfo
WHERE orderinfo.orderid = shippinginfo.orderid
AND shippinginfo.custid = '37782'
AND receivedate = DATE(NOW())
AND receivetime >= (sysdate-1/24);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With