• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 184
  • Last Modified:

Comparing Date in SQL Server 2000

Hi experts,

I have a problem with SQL Server 2000

I have a table Date :
                                          ID                      int 4                NOT NULL
                                          FromDate         datetime 8       ALLOWS NULL
                                         ToDate              datetime 8       ALLOWS NULL

and I want to create a Store Procedure "spCheckDate"  :

         + Input : @InputDate
         + Output : return 1 if FromDate <= @InputDate <= ToDate , else return 0
 
Date table has many rows and I want to check @InputDate with all rows by a store procedure
               
Can everyone help me ? Thanks !!!!
0
trung85gn
Asked:
trung85gn
  • 2
1 Solution
 
Aneesh RetnakaranDatabase AdministratorCommented:
Hello trung85gn,

CREATE PROC spCheckDate
@ImputDate datetime
AS

   IF EXISTS (SELECT 1 FROm [Date] WHERE @inputDate BETWEEN FromDate AND ToDate)
    return(1)
  ELSE RETURN(0)


Aneesh R
0
 
trung85gnAuthor Commented:
Thanks !
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
Thanks for the Grade toooooo :)
I think you need to look in the User guide regading the Grading
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now