Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have this code written so far and it works for what I am doing but if I search for June 13 it will only look up until June 12, can someone help me figure whats wrong in my code? or where I can add a day interval? I tried and its just not working for me.

var db = Database.Open("RMS") ;
var selectCommand = "SELECT * FROM RMS";
var formSSO = "";
var fromDate= "";
var toDate= "";

    formSSO = Request.QueryString["formSSO"];
    fromDate = Request.QueryString["fromDate"];
    toDate = Request.QueryString["toDate"];


selectCommand = "(SELECT * from RMS WHERE SSO LIKE @0)";


if(!Request.QueryString["fromDate"].IsEmpty() ) {
    selectCommand = "SELECT * FROM RMS WHERE SSO LIKE @0 AND Created BETWEEN @1 AND @2";
}

if(Request.QueryString["formSSO"].IsEmpty() ) {
    <div class="simple"><strong>*SSO ID is Required.</strong></div>

}
var data = db.Query(selectCommand, formSSO, fromDate, toDate);
var columns = new[]{"ID", "SSO", "Category", "System", "Subject", "Created"};
var grid = new WebGrid(data, ajaxUpdateContainerId: "grid", defaultSort: "ID", columnNames: columns);
if (Request.QueryString[grid.SortDirectionFieldName].IsEmpty()) {
grid.SortDirection = SortDirection.Descending;
}
}
share|improve this question

1 Answer 1

One thing you can try is using <= and >= instead of BETWEEN like this:

selectCommand = "SELECT * FROM RMS WHERE SSO LIKE @0 AND Created >= @1 AND Created <= @2";

I hope that does the trick!

If not you can also brute force the to date to be one day further into the future and then use the BETWEEN operator just you are now like this:

            DateTime to_date = Convert.ToDateTime(to_date_string);
            to_date = to_date.AddDays(1);
            to_date_string = to_date.ToString();
share|improve this answer
    
Sorry Alexandra try using parse exact the way the answer to this thread shows: stackoverflow.com/questions/14756176/… –  Thomas Fonseca Jun 14 '13 at 21:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.