hai
i want to know that how to compare the two srting's ... i mean i have a date in string 1 and in the second string i have other date
now i want to compare by operant <,>, i convert that string to int but it through error
hai
i want to know that how to compare the two srting's ... i mean i have a date in string 1 and in the second string i have other date
now i want to compare by operant <,>, i convert that string to int but it through error
Converting a date string to an int is why the code failed — dates are not plain integers. Both and pointed toward converting the strings to date/time values, which is correct. The next steps are about parsing reliably (formats and culture) and comparing values in a safe, timezone-aware way so results are consistent across inputs.
TryParseExact) and a known culture to avoid ambiguity. TryParse) with explicit culture and handle failures instead of throwing exceptions. DateTimeOffset if time zones matter). Normalize to UTC when comparing moments from different zones. int (overflow risk). For implementation details and edge cases, see the official docs on TryParseExact for parsing patterns, DateTimeOffset for timezone-aware comparisons, and the standard round-trip format for unambiguous serialization: DateTime.TryParseExact, DateTimeOffset, Round-trip ("O") format specifier.
Jump to Post— reach_yousuf 2Hi there
Check it out this sample code in vbPrivate Function compareDate() As String Dim d1 As String = "01/01/2009" Dim d2 As String = "01/02/2009" Dim strmessage As String If CType(d1, Date) > CType(d2, Date) Then Return strmessage = "greater" ElseIf CType(d1, Date) < CType(d2, …
Hi there
Check it out this sample code in vb
Private Function compareDate() As String
Dim d1 As String = "01/01/2009"
Dim d2 As String = "01/02/2009"
Dim strmessage As String
If CType(d1, Date) > CType(d2, Date) Then
Return strmessage = "greater"
ElseIf CType(d1, Date) < CType(d2, Date) Then
Return strmessage = "Lesser"
End If
End Function Mark as solved if it helps you!!!
In C#:
DateTime time1 = DateTime.Parse("09/11/2000");
DateTime time2 = DateTime.Parse("09/12/2000");
if(time1 > time2) {...} We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.