I have to display records in gridview based on condition - Appointment date = tomorrow date
.
i have tried many options but didn't get exact method. I am using datetime for appointment , it also has time. So I could not remove time and compare date alone.
Now using this query in sqldatasource:
SELECT * FROM [Patient_Appointment_Detail] WHERE ([AptTime] = @AptTime)
and in control parameter using:
<asp:ControlParameter ControlID="lblgetdate" DefaultValue="NULL" Name="AptTime"
PropertyName="Text" Type="DateTime" />
I am putting tomorrows date to label while loading of page. But could not remove time in AptTime and compare only date.
lblgetdate.Text = DateTime.Now.AddDays(1).ToString("dd/mm/yyyy");
I also get this error:
String was not recognized as a valid DateTime. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.FormatException: String was not recognized as a valid DateTime. Source Error: An unhandled exception was generated during the execution of the current web request