Hi
i am getting error - Operator < cannot be applied to operands of type string and DateTime?
C#
if (objGrpResult.GrpSessionStartDate != null)
if (Convert.ToDateTime(ltrlSessionDate).ToString("dd-MM-yyyy") < objGrpResult.GrpSessionStartDate)Thanks

Rajkiran SwainRank #165 · 14.4K reputationPosted Apr 19, 2023, 12:30 PM EDT
if (objGrpResult.GrpSessionStartDate != null && !string.IsNullOrEmpty(ltrlSessionDate.Text)) { DateTime sessionDate = DateTime.ParseExact(ltrlSessionDate.Text, "dd-MM-yyyy", CultureInfo.InvariantCulture); if (sessionDate < objGrpResult.GrpSessionStartDate) { // Your code here } }Rajkiran SwainRank #165 · 14.4K reputationPosted Apr 19, 2023, 11:15 AM EDT
if (objGrpResult.GrpSessionStartDate != null) { DateTime sessionDate = DateTime.ParseExact(ltrlSessionDate, "dd-MM-yyyy", CultureInfo.InvariantCulture); if (sessionDate < objGrpResult.GrpSessionStartDate) { // Your code here } }Ramco RamcoRank #462 · 5.4K reputationPosted Apr 19, 2023, 11:37 AM EDT
Hi Rajkiran
It is giving error - Cannot convert from System.Web.UI.WebControls.Literal to string on ltrlSessionDate in below line
DateTime sessionDate = DateTime.ParseExact(ltrlSessionDate, "dd-MM-yyyy", CultureInfo.InvariantCulture);
Thanks