Click here to Skip to main content
15,907,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone I'm trying to check invoice delivery if it's 'on time','late' or 'due date' in sql query, im using SQL Server. how can i implement if statement on my t-sql?

'check nvoice date and due date
IF table1.invoiceDate <= table2.dueDate then
end if

if table1.invoiceDate >= table2.dueDate then
'Late Delivery'
end if

IF table2.dueDate <= CONVERT(VARCHAR,GETDATE(),110) then
'on due'
end if
Updated 14-Apr-14 15:15pm
[no name] 14-Apr-14 21:24pm
So, what is the issue?

1 solution

A complete explanation of how to use IF...ELSE.. in T-SQL is available here[^]

Hope this Helps
Share this answer
Cuculala 14-Apr-14 22:59pm    
Thanks for help guys, but i want my status to be seen like this

|supplier | PONumber | DueDate | DateDelivered | Status
|supplier1| 123 | 4/12/2014 | 4/15/2014 | late delivery
Cuculala 14-Apr-14 23:02pm    
the above result is just an example, im trying to create a view with status so user can see the status of its order, if its late, on time, or on its due date.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900