c# - Only display dates after current date from database in datagridview -


so have database, , querying list of events , there dates. want change query return events have not occured.

my query @ moment is:

cmd.commandtext = "select eventid, eventdate, location events"; 

and inputs datagridview.

i tried:

cmd.commandtext = "select eventid, eventdate, location events eventdate > curdate()"; 

but didnt return dates.

here have approach both mssql , mysql since did not specify dbms using.

mssql:

you can use getdate(). should give current date , time.

cmd.commandtext = "select eventid, eventdate, location events eventdate > dateadd(dd, datediff(dd, 0, getdate()), 0)"; 

mysql:

you can use now() function, , truncate time part casting date.

cmd.commandtext = "select eventid, eventdate, location events eventdate > cast(now() date))"; 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -