Finding closest match .. problem persists!

Results 1 to 2 of 2

Thread: Finding closest match .. problem persists!

  1. #1
    Join Date
    Dec 1969

    Default Finding closest match .. problem persists!

    I have a page that takes user input and returns the itemnames corresponding to the search criteria .. its wokring fine, but i want to add the functionality of the closest match , so if say the date field entered by user doesnt returns any record ... it searches for the closest date ... can I get the record for a time range like if user enters 10/29/01 and it looks for say 21 days ahead and forth?? ... <BR><BR>I am using sproc for the query ...<BR>I tried using DATEADD function but couldnt figure it out..<BR><BR>Here is my sproc :<BR><BR>CREATE PROCEDURE customerinquiry<BR> @RoutingNumber varchar(30),<BR> @AccountNumber varchar(30),<BR> @Amount money,<BR> @EntryDate datetime,<BR><BR>@datehigh= DATEADD( day , 21 , EffectiveEntryDate),<BR>@datelow= DATEADD( day , -21 , EffectiveEntryDate)<BR><BR>AS<BR>SELECT Title<BR>FROM Profile<BR>WHERE RoutingNumber = @RoutingNumber AND<BR> AccountingNumber = @AccountNumber AND<BR> Amount = @Amount AND<BR> EntryDate = BETWEEN @datelow AND @datehigh<BR>Return 0<BR><BR>I know the @datehigh and @datelow fields are misplaced .. but i just couldnt figure it out where to put them....I tried adding the "dateadd" function in my asp page but that didnt work either ...<BR><BR>Any advice/guidance is highly appreciated ..Thanks in advance...

  2. #2
    Join Date
    Dec 1969

    Default RE: Finding closest match .. problem persists!

    well<BR><BR>i never use between (don&#039;t know why)<BR><BR>but why not just say<BR><BR>where ((entrydate &#062;= @datelow) AND (entrydate &#060;= @datehigh))<BR><BR>not sure of the dateadd syntax, check the tsql help (if using sql server 7,2k)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts