Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 calculate datevalues

Author  Topic 

roxcy
Yak Posting Veteran

58 Posts

Posted - 2006-08-07 : 04:01:26
Hi,
I want to calculate dates using storedprocedures.The condition is when the user selects dates as 2nd Aug2006 to1st Aug2007 it should validate with the table where year has already been defined for eg in my case I have a Table Year where the values are 1year,2 year...when the user selects period of one year it should check for the existence in my table Year and vice versa.
Hope u can find me a solution .......
Any help would be appreciated.....
Thanks in Advance

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-08-07 : 04:10:17
can you post your table structure, some sample data and the result that you want ?


KH

Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-08-07 : 04:17:27
Well it will be better if you can post some sample data..

Just check if this satisfy your requirment.

If Exists (Select * From [Year] Where <YearColumn> = (DateDiff(Month,'20060802','20070801')/12)


Chirag
Go to Top of Page

roxcy
Yak Posting Veteran

58 Posts

Posted - 2006-08-07 : 05:49:32
Hi Khtan,
I am using two datecontrols ie fromdate and todate.On selecting the dates i want to check whether the dates selected is for the period of 1 year 2 year.I would like 2 check this using stored procedures.So how should i do the calculation part?Hope u got my point...
Roxcy..
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-08-07 : 05:59:35
Somthing like this..??

Create Proc CheckPeriod
(
@pStartDate DateTime,
@pEndDate DateTime,
@pInterval int out
)
As
Begin
Select @pInterval = Datediff(month,@pStartDate,@pEndDate)/12
return @pInterval
End


This will return you the interval in the variable @pInterval.


Chirag
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-08-07 : 08:50:53
Why do you have year table seperately?
http://www.sql-server-performance.com/fk_datetime.asp


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -