0

Possible Duplicate:
SQL query to select dates between two dates

how to fetch record between two dates in sql server 2008. im using I-batis query

eg.

 select * from T_SETTLEMENT_TRANSACTION WHERE status='PEND' and from_date_time >='2013-01-09 04:16:52.0' AND to_date_time<='2013-01-09 04:16:52.0' 

where two columns are in datetime format in Sql server 2008

0

1 Answer 1

3

You could use SQL 2005's BETWEEN operator i.e.

WHERE createdate BETWEEN '01-01-01 21:20:32.71' AND '10-01-01 21:20:32.71'

Edit: If you want to fetch data between two different fields you should be able to do the following

WHERE createdate >= from_date AND createdate < to_date

Let me know how it works!

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Bill. One more query.Suppose if im selecting from two columns.what i have to change.(say for From _date column and To_date column)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.