Click here to Skip to main content
15,887,596 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?

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

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

IF table2.dueDate <= CONVERT(VARCHAR,GETDATE(),110) then
'on due'
end if
Posted
Updated 14-Apr-14 15:15pm
v2
Comments
[no name] 14-Apr-14 21:24pm    
http://technet.microsoft.com/en-us/library/ms182717.aspx
So, what is the issue?

1 solution

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

http://technet.microsoft.com/en-us/library/ms182587.aspx[^]

Hope this Helps
 
Share this answer
 
Comments
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