Hello everyone i want to find difference of two dates but i am getting an error. can anyone can guide me how to resolve it.
Conversion from string “27-07-2023” to type ‘Date’ is not valid.
Kindly go through the attached image.
Hello everyone i want to find difference of two dates but i am getting an error. can anyone can guide me how to resolve it.
Conversion from string “27-07-2023” to type ‘Date’ is not valid.
Kindly go through the attached image.
Instead od cdate use this
Datetime.ParseExact(datevar,"dd-MM-yyyy",System.Globalization.CultureInfo.InvariantCulture)
If the format is different then change this accordingly dd-MM-yyyy
Cheers
Format for both the dates are same. dd-MM-yyyy
@Ashish_Tyagi
Try this
Cint(DateDiff(DateInterval.Day, Datetime.ParseExact(Today_date,“dd-MM-yyyy”,System.Globalization.CultureInfo.InvariantCulture),Datetime.ParseExact(Invoice_Date,“dd-MM-yyyy”,System.Globalization.CultureInfo.InvariantCulture)))
Try this one
Cint(DateDiff(DateInterval.Day,Datetime.ParseExact(Today_Date,"dd-MM-yyyy",System.Globalization.CultureInfo.InvariantCulture),Datetime.ParseExact(Invoice_Date,"dd-MM-yyyy",System.Globalization.CultureInfo.InvariantCulture)))
Please use the above provided one…and this error is because of wrong inverted comma…change them in code
correct: "
wrong: ”
cheers
@Ashish_Tyagi
Try to convert inverted Commas “” as Anil mentioned. When we write here it changes to wrong one.
Cint(DateDiff(DateInterval.Day,Datetime.ParseExact(Today_Date,"dd-MM-yyyy",System.Globalization.CultureInfo.InvariantCulture),Datetime.ParseExact(Invoice_Date,"dd-MM-yyyy",System.Globalization.CultureInfo.InvariantCulture)))
@Ashish_Tyagi
If your problem solved then mark it as a solution so that others can get help from it. Thanks
Cdate by default converts the date which is in your system date format only…any other formats need to be converted using parseexact method…
hope this helps
Cheers
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.