Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date problem

Status
Not open for further replies.

baran121

Programmer
Sep 8, 2005
337
TR
hi.
i want to do a query about date. there is the code


select * from ab_date_def order by sdate between '2008-01-01'
and '2008-03-30' order by sdate

sdate:
2008-03-03 16:52:00
2008-03-07 15:12:00
2008-03-28 14:14:00
2008-01-25 17:45:00
2008-01-25 17:46:00
2008-03-03 16:52:00

i want to get in where only date not time.
plase help me


 
Code:
select * 
      from ab_date_def
WHERE sdate >= '20080101' and sdate < '20080401'
order by sdate

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
Microsoft MVP VFP
 
Hi baran121,

You can get the result with this.
Code:
select 
  CONVERT(DATETIME, FLOOR(CONVERT(FLOAT, sdate))))  
from 
  ab_date_def 
where
  sdate between '2008-01-01' and '2008-03-30' 
order by 
  sdate

By the way,
You need to take care the condition too when you use the datetime.

This SQL excludes 2008-03-30 11:00:00 data.


koichi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top