Results 1 to 2 of 2

Thread: Date

  1. #1
    Join Date
    Jul 2005
    Posts
    24

    Date

    hi,
    there is one table which is having one field for date i.e. tdate, now i want to display those records for which i have given the date span e.g. if i enter date span 01/08/2005 - 15/08/2005 in the form, then i want all the records containing these dates, if any date between this date span missing means not present in table then it should not display any record.

    plz help me

  2. #2
    Join Date
    Aug 2003
    Location
    London
    Posts
    110
    create table test (a datetime,b int) -- b is the sample for data you can have as menay data sa you wantgo

    create function dbo.test_fn (@from_date datetime,@to_date datetime)
    returns char
    as
    begin
    declare @flag char,@main_count int,@count int
    select @flag='N'
    select @main_count=count(*) from test
    select @count=count(*) from test where a between @from_date and @to_date
    if (@count=@main_count) set @flag= 'Y'
    return @flag
    end

    go

    select * from test where dbo.test_fn( '2005-05-01', '2005-05-05')='Y'

    It will display the result only if the dates given cover all the data in the table.

Posting Permissions

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