flyclassic22
Technical User
How do i insert a sql and asp.net datetime functions and date now to come up with a sql statement to select data which are within now and 30days ago?
Any examples???
Any examples???
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
DateTime today = DateTime.Today;
DateTime ThrityDaysAgo = DateTime.Today.AddDays(-30);
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "select * from [table] where [field] bewteen @start and @end";
cmd.Parameter.Add(new Parameter("start", SqlDbType.DateTime, ThrityDaysAgo);
cmd.Parameter.Add(new Parameter("end", SqlDbType.DateTime, today);
string selectquery = "SELECT [ImagePath], [Description], [Price], [DateRelease], [productID] FROM [CDCatalog] WHERE DateRelease BETWEEN '" + sixtydaysago.ToString() + "' AND '" + todaydate.ToString() + "'";
string selectquery = "SELECT [ImagePath], [Description], [Price], [DateRelease], [productID] FROM [CDCatalog] WHERE DateRelease BETWEEN @start AND @end";