I have this and wish to display future date and today date how can it be done?
Date
-----------
10/08/2014
09/08/2014
11/08/2014
and I only wish to display
10/08/2014
11/08/2014
Most versions of SQL have some way of getting the current date. For instance:
where date >= cast(CURRENT_TIMESTAMP as date)
where date >= cast(getdate() as date)
where date >= date(now())
where date >= trunc(date)
The specific syntax you need depends on the database you are using.
EDIT:
The first or second versions should work with SQL Server Express.
SQL will consider your date "11/08/2014" in mm/dd/yyyy format by default. You would need to rearrange the month before the date like "08/11/2014" before making the comparison. Below code will get you the required results:
SELECT CONVERT(VARCHAR(20),CAST(Time AS DATE),120)
FROM Table
WHERE CONVERT(VARCHAR(20),CAST(Time AS DATE),120)>=CONVERT(VARCHAR(20),GETDATE(),120)
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.