简体   繁体   中英

I can't retrieve the Date greater than or equal to a specific date in Sql.

String sql="select * from offerpoolride 
WHERE date >= '1997-05-05'";

I am a beginner and Can anyone please help me how to retrieve those?

I'm not 100% sure about ANSI-SQL, but in T-SQL you would use the following:

SELECT * FROM TABLE WHERE [date] >= '19970505'

So the date is input in format 'yyyyMMdd'. I am assuming your field is called date...

use backtick for date

SELECT * FROM `offerpoolride` WHERE `date` >= '1997-05-05';

you should be comparing dates as dates

String sql="select * from offerpoolride WHERE date(my_date) >= date '1997-05-05'";

It should do your job.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM