ขอร่วมแบ่งปันความรู้ครับ
รูปแบบการใช้ DATEDIF
DATEDIF(start_date, end_date, unit)
start_dateThe date that represents the starting date of the period.
end_dateThe date that represents the finishing date of the period
unitThe type of information you want returned
"D" = number of days between the "start_date" and "end_date"
"M" = number of complete months between the "start_date" and "end_date"
"Y" = number of complete years between the "start_date" and "end_date"
"MD" = difference between days in "start_date" and "end_date"
"YD" = difference between the days of "start_date" and "end_date"
"YM" = difference between the months in "start_date" and "end_date"
=DATEDIF("01/07/2010","01/08/2010","m") ค่าที่ได้คือ1
=DATEDIF("01/07/2009","01/08/2010","m") ค่าทีึ่ได้คือ13
=DATEDIF(D1,TODAY(),"y")&" years "&DATEDIF(D1,TODAY(),"ym")&" months "&DATEDIF(D1,TODAY(),"md")&" days" ค่าที่ได้คือ2 years 2 months 20 days
หรือศึกษาจากเวปของอาจารย์ที่นี้ครับ
http://snasui.blogspot.com