Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 Need Help in Expiry Date Calculation

Author  Topic 

derozza
Starting Member

13 Posts

Posted - 2010-10-25 : 04:51:19
Dear Master²

I have problem with Expiry Date Calculation this my code:-

SELECT DISTINCT t_grndetail.ExpiryDate as ExpiryDate, t_grndetail.BatchCode as BatchCode, mas_itemsellingprice.ProductCode as ProductCode, mas_itemsellingprice.Description as Description, mas_itemlocation.ItemCode as ItemCode, t_grndetail.LocationCode as LocationCode  FROM mas_itemsellingprice, mas_itemlocation, t_grndetail WHERE t_grndetail.ItemCode = mas_itemsellingprice.ItemCode AND mas_itemlocation.ItemCode = mas_itemsellingprice.ItemCode AND mas_itemsellingprice.ProductCode = '4800361331100' AND DateDiff('2010-10-25',t_grndetail.ExpiryDate)BETWEEN 0-30 AND t_grndetail.ExpiryDate >= '2010-10-25' ORDER BY t_grndetail.ExpiryDate ASC


What i'm doing query is. Showing upcoming expiry date from current date let say " today" and next 1 month,2 month, 3 month, 4 month, 5 month, 6 month & 7month & above.

which is showing in my table:-

|ExpiryDate|BatchCode|ProductCode|Description|ItemCode|LocationCode|

Thank u in advance

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-10-28 : 03:38:02
First: nobody likes to read your post if we have to scroll miles to right.
Second: a proper formatted query would be fine. (I'll paste a formatted query here...)
Third: Please give DDL, sample data and wanted result to make more clear what you want.

Thanks
SELECT DISTINCT t_grndetail.expirydate           AS expirydate, 
t_grndetail.batchcode AS batchcode,
mas_itemsellingprice.productcode AS productcode,
mas_itemsellingprice.DESCRIPTION AS DESCRIPTION,
mas_itemlocation.itemcode AS itemcode,
t_grndetail.locationcode AS locationcode
FROM mas_itemsellingprice,
mas_itemlocation,
t_grndetail
WHERE t_grndetail.itemcode = mas_itemsellingprice.itemcode
AND mas_itemlocation.itemcode = mas_itemsellingprice.itemcode
AND mas_itemsellingprice.productcode = '4800361331100'
AND Datediff('2010-10-25', t_grndetail.expirydate)BETWEEN 0 - 30 AND
t_grndetail.expirydate >= '2010-10-25'
ORDER BY t_grndetail.expirydate ASC



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -