Get last 30 day records from today date in SQL
This query will show 30days Record only
SELECT a.*,b.* from olx.sp_item a,olx.sp_item_photo b where a.ITEMID=b.ITEMID and a.ITEM_CATEGORY='Appliance' and a.ACTIVE_FLAG='Y' and add_months(a.ENTER_DT,1)>SYSDATE;
This query will show 2days Record only
SELECT a.*,b.* from olx.sp_item a,olx.sp_item_photo b where a.ITEMID=b.ITEMID and a.ITEM_CATEGORY='Appliance' and a.ACTIVE_FLAG='Y' and (a.ENTER_DT+2)>SYSDATE;
You can use DateDiff
for this. The where clause in your query would look like:
where DATEDIFF(day,pdate,GETDATE()) < 31
Post a Comment
0Comments