SQL Select Where Date <= To date

317 views Asked by At

Hi I am a newbie in SQL syntax.

I would like to have a query results in SQL using the below syntax.

Select * from tblSales where duedate <= todate

But when i run it was an error.

Please advise me for the correct syntax.

Thanks

3

There are 3 answers

0
Daryl On BEST ANSWER
select * from(
select datediff(day,getdate(),Duedate )as Diff,
SInumber ,InvoiceNo,Customer ,Tradedate,PaymentTerms,Duedate,Amount   
from tblSales )as D where DIFF <= '10'

This is the Query i want..and it solved!

2
Bayu Prawira On

You could try this:

SELECT * FROM tblSales WHERE DATE(duedate) <= CURDATE();

I don't test it yet. Hope it works

4
Sachu On

In your question the RDBMS is not mentioned..

For SQL Server your query should be

Select * from tblSales where duedate <= GETDATE()

where GETDATE() return the current system date and duedate should be a date datatype.

If you are using oracle to get current system date you can use SYSDATE