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.
| Author |
Topic |
|
vedjha
Posting Yak Master
228 Posts |
Posted - 2008-12-15 : 06:35:11
|
| I m using My SQL. Here Date is a column and its datatype is varchar.i have to compare the dateas in SQl serverselect * from tablename where date between '1/1/2008' and '5/5/2008'how to query in My Sql .plz help meVed Prakash Jha |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2008-12-15 : 06:53:50
|
| select * from tablename where convert(datetime , date) between '1/1/2008' and '5/5/2008'select * from @tb where cast(date as datetime) between '1/1/2008' and '2/5/2008' |
 |
|
|
vedjha
Posting Yak Master
228 Posts |
Posted - 2008-12-15 : 07:00:29
|
| Thnks 4 query...but it will work on sql serveri need query for my sql...Ved Prakash Jha |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-15 : 07:15:47
|
| then you must be posting this on MySQL forums like www.dbforums.com |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2008-12-15 : 07:21:25
|
| sorry vedjha, i don't know it will work in mysql or not my query will work in sql 2005 |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-12-15 : 09:18:08
|
quote: Originally posted by vedjha I m using My SQL. Here Date is a column and its datatype is varchar.i have to compare the dateas in SQl serverselect * from tablename where date between '1/1/2008' and '5/5/2008'how to query in My Sql .plz help meVed Prakash Jha
In MYSQLselect * from tablename where cast(date as date) >='2008-01-01' and cast(date as date)<'2008-05-06'MadhivananFailing to plan is Planning to fail |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2008-12-17 : 10:26:47
|
| HiUse like thisselect * from tablename where cast( date as datetime) between '1/1/2008' and '5/5/2008'Be cool... |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-17 : 10:45:09
|
quote: Originally posted by raky HiUse like thisselect * from tablename where cast( date as datetime) between '1/1/2008' and '5/5/2008'Be cool...
and how do you think this is different from what bklr posted 2 days back? |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-12-24 : 02:04:15
|
quote: Originally posted by raky HiUse like thisselect * from tablename where cast( date as datetime) between '1/1/2008' and '5/5/2008'Be cool...
See my previous reply which is more effecientMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|