Quantcast
Channel: WinDev Forum
Viewing all articles
Browse latest Browse all 1914

[WD20] Best way to find out if a date is between 2 other dates (1 reply)

$
0
0
Hello All

The situation is to find a sell price for a stock item.
There is a price contract record attached to a debtor and then stock items are attached to the price contract with prices valid for that contract. The contract has a start and finish date which can be a few months or a year or so.
A debtor invoice has a transaction date so when a line on the invoice requests a sell value for a stock item I need to check if there is a current contract for the debtor where the invoice date is between the start and end dates of the contract.

At the moment I am using Hfilter()
sBrowseKeyItem is string
sBrowseKeyItem = HFilter(DSrvCont, "DRCLEUNIK='"+Debtor.DRCLEUNIK+"'"...
+" AND StartDate<="+InvoiceDate+""...
+" AND EndDate>="+InvoiceDate+""...
+" AND ActiveStatus=1")
IF HReadFirst(DSrvCont, sBrowseKeyItem)
       //There is a valid contract
	//Go and see if there is a stock item match
ELSE
       //There is no contract so get the value another way
END //IF HReadFirst(DSrvCont, sBrowseKeyItem)

I have also used a query and then tested to see if a record was returned.

Both methods work but seem clumsy so I am asking if there is a better way ?

Regards
Al

Viewing all articles
Browse latest Browse all 1914

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>