views:

84

answers:

2

How do you calculate a date value in a stored procedure? This:

CStr(DateAdd("m", -6, Date))

Is the line in the original code and I am wondering if rather than pass the value to the stored procedure if I can calculate that value in the stored procedure but not sure how to do it?

+1  A: 

If you are talking SQL Server then it has a dateadd function:

To duplicate your ASP Code it would look something like: DATEADD("m",-6,GETDATE())

Here's the list of SQL Server Date Functions:

http://msdn.microsoft.com/en-us/library/ms186724.aspx

klabranche
Thanks, that was the info I was looking for.
flavour404
A: 

In you stored procedure you can use GETDATE() to get the current date, unless you want to pass in the date, but, I tend to prefer to use the database computer's clock, so that all dates are based on the same clock.

Your question is bit vague, I am not certain if you want to calculate the date in the stored procedure, or get a date that was returned from a stored procedure, so I assumed the former.

James Black