Hello everybody!!
somebody help me to determinate how can I get the difference between two dates?
For example (yyyy-MM-dd):
Date1= 2016-01-30
Date2=2016-02-01
The result will be 2 ( two days is the interval between that dates)
Hello everybody!!
somebody help me to determinate how can I get the difference between two dates?
For example (yyyy-MM-dd):
Date1= 2016-01-30
Date2=2016-02-01
The result will be 2 ( two days is the interval between that dates)
Hello!
You can use the DateDiff function.
Example:
Syntax: DateDiff(DateInterval, Date1,Date2)
Code: DateDiff(DateInterval.Day, “2016-01-30”,“2016-01-30”)
It will return the number of the days between the two dates as Integer Type.
Hope It helps!
Regards,
Good!!
Your solutions is perfect.
Thank you
Hi
You can also use like this
Date2.Subtract(date1)
Is it possible to calculate for months?
Attached is the example
monthDiff.xaml (7.1 KB)
can someone help me to calculate date diff between date format in “11-Apr-2018” and today(). I want to find out if this date is 4 weeks old or not.
Hi @harjyot123,
Try this code
DateDiff(DateInterval.Day,DateTime.ParseExact(str_Date, "dd-MMM-yyyy", CultureInfo.InvariantCulture),DateTime.now())
Regards,
Arivu
It gives me an error saying culture info is not declared. I also imported “System.globalization”.
DateDiff(DateInterval.Day,DateTime.ParseExact(str_Date, "dd-MMM-yyyy", System.Globalization.CultureInfo.InvariantCulture),DateTime.now())
Can anyone share the syntex
if I want to use date columns itself instead of value for select query.
Also can datediff can be used in update query also.
Yes,
SELECT DATEDIFF(month, ‘2017/08/25’, ‘2011/08/25’)