We help IT Professionals succeed at work.
Get Started

Query help date range

294 Views
Last Modified: 2010-08-05
Hi,

I am working on MSSQL 2000


I want query help

I want data between the date range

The date in the database is in the form 2007-04-23 17:23:57.280

I wish to pass the date in the form dd/mm/yyyy

If I pass the date in the form dd/mm/yyyy or

SET @FROMDATE = '23/04/2007'

Then I get the error

The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

Also, If I pass the date in the form

SET @FROMDATE = '2007-04-23'
SET @TODATE = '2007-04-23'

Then I do not get any result. But if it is in the below form then the result comes

Please help

Below is my query



DECLARE
@FROMDATE DATETIME,
@TODATE DATETIME

 
SET @FROMDATE = '2007-04-23 17:23:57.280'
SET @TODATE = '2007-04-23 17:23:57.280'


SELECT TOP 1 *
         FROM MODLOG  
         WHERE
DATEACTION BETWEEN   @FROMDATE  AND @TODATE
 

          ORDER BY DATEACTION DESC
         
         
Thanks
Comment
Watch Question
Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009
Commented:
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE