At this time when i click a highlighted date that i know has a record, it will only show a matching record if it has a Date and Time stamp of 12:00:00 attached to it. However the database has DateTime for when the record was created by the user.
Basically i want the SQL statement triggered by the SelectedDate property of the Calendar control to only send the format Month,Day,Year. I'm not sure how i can control this.
At this time, my code is inline for the clicking of the date to populate the RadGrid. The only codebehind is the code that displays the different background for SelectedDates with a record(s).
think the other part to mention is that there are two things to keep in mind.
1. The input from the Calendar Control which become the WHERE in my SQL Statement
1. Running my SQL statement
2. And outputing the date on the page (through RadGrid control)
I need to keep straight all of the inputs and outputs and make sure the formats are what i expect.
So, when i click a date on the calendar control. Which is @ArticleDateTime in the WHERE clause. This needs to be sent in the Date format (no time).
| <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:LionsConnectionString %>" |
| SelectCommand="SELECT ArticleID, ArticleTitle, ArticleSubject, ArticleContent, ArticleDateTime, ArticleExp, ArticleExpChkBox, UserID, UserName FROM tblLionsArticles WHERE ((ArticleDateTime) = @ArticleDateTime)"> |
| <SelectParameters> |
| <asp:ControlParameter ControlID="RadDatePicker1" DefaultValue="1/1/2008" Name="ArticleDateTime" |
| PropertyName="SelectedDate" /> |
| SelectParameters> |
| asp:SqlDataSource> |
I need to somehow accept only the Date from the calendar parameter, as well as the database understand only the date even though the SQL database has DateTime.
I having a hard time understanding how to accept only Date and SQL do a SELECT only for Date and then return only the Date value.
thanx
Nilanka DharmadasaPosted Nov 5, 2009, 12:24 AM
Change your select command as follows.
SELECT ArticleID, ArticleTitle, ArticleSubject, ArticleContent, ArticleDateTime, ArticleExp, ArticleExpChkBox, UserID, UserName FROM tblLionsArticles WHERE (convert(datetime, convert(char, ArticleDateTime, 106)) = @ArticleDateTime)
If my answer helps you please do not forget to accept my answer.
Thanks