Click here to Skip to main content
15,893,337 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can calculate amount such that:
amount = (current date - end date) * 2
How to write code in SQL to achieve the same.
Posted
Updated 2-Jan-15 0:05am
v2
Comments
Snesh Prajapati 2-Jan-15 6:06am    
Hi krisna...I have updated the question...please check if you need the same only...or make it more clear. Thanks.
krishna97 2-Jan-15 6:10am    
SELECT DATEDIFF(day, GETDATE(), ReturnDate)*(select FineLimt from tbl_LibryMemberCategory)

from tbl_LibraryBookIssue

this query used
krishna97 2-Jan-15 6:11am    
find out day and multiply by this table select FineLimt from tbl_LibryMemberCategory
Snesh Prajapati 2-Jan-15 6:13am    
Is that all working fine now ? or what is error now ?
krishna97 2-Jan-15 6:16am    
out put can not given for this query

Try
SQL
SELECT DATEDIFF(d, GETDATE(), endDate) * 2 AS [Days times 2] FROM MyTable
 
Share this answer
 
Following code will do that:
SQL
DATEDIFF(day,endDate,currentDate) * 2

If needed you can write an "if" confition to check whether output of above code is positive integer or not.
For more: http://msdn.microsoft.com/en-IN/library/ms189794.aspx[^]

Thanks.
 
Share this answer
 
v3

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