Difference b/w two dates

Difference b/w two dates ,one date is provided by excel column and another date is provided by Now present date,how can I find diffence b/w to dates excel and Present date.

I am doing write a syntx like this showing a error

Hi @killarapusiva,

The method used is correct. Probably your date formats don’t match. Can you try this way

DateDiff(DateInterval.Day, Convert.ToDateTime(Convert.ToDateTime(pastdate).toString("dd/MM/yyyy")),Convert.ToDateTime(Convert.ToDateTime(date2).toString("dd/MM/yyyy"))).toString

Regards,
MY

Hi,

As another possibility, prefix namespace might be lacked. So can you try the following expression?

Microsoft.VisualBasic.DateAndTime.DateDiff(Microsoft.VisualBasic.DateInterval.Day,Convert.ToDateTime(pastdate),Convert.ToDateTime(date2),Microsoft.VisualBasic.FirstDayOfWeek.Sunday,Microsoft.VisualBasic.FirstWeekOfYear.System).ToString()

Regards,

DateDiif(Dateinterval.Day,DateTime.ParseExact(“Date1”,“Format”,Globalization.CultureInfo.InvariantCultue),DateTime.ParseExact(“Date2”,“Format”,Globalization.CultureInfo.InvariantCultue))

Output(Data type : int32)

orElse

DateDiff(DateInterval.Day,CDate(“05/05/2022”),Now)

1 Like

@killarapusiva Can you let us know what is the error it is giving