Replies |
Hi,
The above query is working fine.
Note: pls try the date format as in sqlserver i.e yyyy-mm-dd
select * from tbl_XXXXX
where col_XXXXX>='2010-12-31' and col_XXXXX<='2011-01-02'
Sravanthi.seeta, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|
PandianS
Posted on: 1/3/2011 4:01:10 AM
|
Level: Silver | Status: [Member] [MVP] | Points: 25
|
You can use either one of the following way using( >= and <= OR Between )
declare @StartDate DATETIME,
@EndDate DATETIME
select @StartDate = '2011/01/02',
@EndDate = '2011/01/03'
select * from TB_Table1 where CONVERT(VARCHAR,col2,111) >= @StartDate
and CONVERT(VARCHAR,col2,111) <=@EndDate
OR
declare @StartDate DATETIME,
@EndDate DATETIME
select @StartDate = '2011/01/02 00:00:00',
@EndDate = '2011/01/03 23:59:59'
select * from TB_Table1 where col2 >= @StartDate
and col2 <=@EndDate
OR
declare @StartDate DATETIME,
@EndDate DATETIME
select @StartDate = '2011/01/02 00:00:00',
@EndDate = '2011/01/03 23:59:59'
select * from TB_Table1 where col2 between @StartDate and @EndDate
Cheers
www.sqlserverbuddy.blogspot.com
Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions
Sravanthi.seeta, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|
Karthikanbarasan
Posted on: 1/5/2011 4:45:33 AM
|
Level: Silver | Status: [Member] [Moderator] [Microsoft_MVP] [MVP] | Points: 25
|
Hi,
You can use between clause to find the records between 2 dates
Select * from table1 where strcreateddate between 'date1' and 'date2'
Thanks
Karthik
www.f5Debug.net
Sravanthi.seeta, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|
SELECT * FROM TABLENAME WHERE DATEJOIN IN(STATEDATE,ENDDATE)
SELECT * FROM TABLENAME WHERE DATEJOIN BETWEEN STARTDATE AND ENDDATE
REGARDS
sriram
Sravanthi.seeta, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|
Ajay.Kalol
Posted on: 6/4/2012 1:48:42 AM
|
Level: Starter | Status: [Member] | Points: 25
|
select * from tbl_XX
where col_XX BETWEEN '2010-12-31' and '2011-01-02'
http://ajaypatelfromsanthal.blogspot.in
Sravanthi.seeta, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|
hi
u can use this query
example i give some fromdate and todate:
select dtfromdate,dttodate from tblhr_specialleavetransaction where
((dtfromdate >= '2012-04-25 00:00:00' and dttodate <= '2012-07-25 00:00:00')
or (dtfromdate <= '2012-04-25 00:00:00' and dttodate >= '2012-07-25 00:00:00')) Regards
Kavi.n
Sravanthi.seeta, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|
CGN007
Posted on: 6/5/2012 2:25:51 AM
|
Level: Silver | Status: [Member] | Points: 25
|
The simple query is
SELECT * FROM table1 WHERE date_column BETWEEN 'startdate' AND 'enddate'
Sravanthi.seeta, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|
Meet1424
Posted on: 6/5/2012 3:44:06 AM
|
Level: Starter | Status: [Member] | Points: 25
|
Select * from table1 where date_field between 'startdate' and 'enddate'
Sravanthi.seeta, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|
Svandanapu
Posted on: 6/5/2012 10:42:48 AM
|
Level: Starter | Status: [Member] | Points: 25
|
Use Between operator with two different dates
Sravanthi.seeta, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|
CGN007
Posted on: 6/23/2012 10:06:19 AM
|
Level: Silver | Status: [Member] | Points: 25
|
Mark as Answer if its helpful to you,that motivates...
Sravanthi.seeta, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|
how to do if u have only one order_date column in table and want to show multiple order of an party between 2 date
Sravanthi.seeta, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|
Sumank
Posted on: 5/9/2013 7:01:03 AM
|
Level: Starter | Status: [Member] | Points: 25
|
You can use between clause for finding records between start_dt and end_dt :
select * from tblName where date between 'start_dt' and 'end_dt'
Regards
SumanK
Sravanthi.seeta, if this helps please login to Mark As Answer. |
Reply | Alert Moderator
|