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 2005 Forums
 Transact-SQL (2005)
 datetime issue

Author  Topic 

gems
Starting Member

19 Posts

Posted - 2007-04-11 : 10:04:11
Hi,

I have a datetime field in my table called start_date_time of type datetime. I created a parameter called @end_date in my stored procedure. The code looks something like this

start_date_time <= @end_date

Right now if a user enters just date, computer picks up the current time from the PC clock and does not return records for that particular day after the time the query was run. So if a user enters end_date as 03/01/2007, it will return records for 03/01/2007 for only upto 10:00 am. I want it show records for the entire day. Is there a way that I can ignore the time part and just check the date value?

I am using SQL server 2000.

Thanks

-G

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-04-11 : 10:06:12
try

start_date_time < dateadd(day, datediff(day, 0, @end_date), 1)



KH

Go to Top of Page

gems
Starting Member

19 Posts

Posted - 2007-04-11 : 10:40:27
Thanks KH. But it is still not working.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-04-11 : 10:44:37
maybe you should post your table structure, some sample data and the required result.


KH

Go to Top of Page

gems
Starting Member

19 Posts

Posted - 2007-04-11 : 11:14:59
hey KH.. actually it is working fine if I run it in query analyzer but when I run my report in Crystal reports which uses this stored procedure, I don't get the right result.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-04-11 : 11:17:23
Does it give you the right result if you run the stored procedure in QA ?


KH

Go to Top of Page
   

- Advertisement -