Last post Sep 13, 2016 05:27 AM by Deepak Panchal
Aug 28, 2016 12:37 PM|sivapooja|LINK
Hi how to calculate our own formula
formulaTxt = "A+B*((C-D)/(A-D))"
A,B,C and D are sqlserver table columns, can i send this formula to sql to execute and get back the result? if those columns are Date or DateTime columns then can manipulate with fixed date values for example "[A]-getdate()" or "[A] + [21-May-2016 05:00:00
Aug 29, 2016 05:59 AM|sreejukg|LINK
You can write a stored procedure in SQL Server that accepts these parameters and return the result.
You can retrieve the values from SQL Server and perform the calculation in your code.
Aug 29, 2016 12:09 PM|sivapooja|LINK
integer column no issue but if date columns how to perform the calculation
formula = "(([A] - [B]) + ([C] - [D]))"
Aug 29, 2016 01:27 PM|limno|LINK
You need to use dateadd and datediff functions.
Aug 31, 2016 09:14 AM|balu.devara|LINK
using datediff you can calculate difference b/w 2 dates like bellow,
SELECT DATEDIFF(day,'2014-08-05','2014-06-05') AS DiffDate
Aug 31, 2016 09:33 AM|techviju|LINK
create a scalar value function for the formula and call that when you required.
Sep 13, 2016 05:27 AM|Deepak Panchal|LINK
first here I think that fetching the value from database into Asp.net and then perform calculation is the easiest solution for this requirement.
you had mentioned that you don't have any problem regarding calculating integer but you have problem with dates.
but you did not post any code. so here we don't know exactly that how you are trying to calculate this formula.
whether you are trying to calculate in sql or in Asp.net.
where you stuck in the code. did you got any error or exception?
please let us know so that we can try to suggest you appropriate suggestion.
otherwise we just try to assume the situation and give the suggestion. which not work always.