Find the difference between two dates.
dateDiff("d", "2013-01-15", "2013-01-25")
Expected Result: 10
Calculates a persons age based on a variable birthDate which contains a date. Uses the now function to get current date.
birthDate = createDate( 1972, 5, 20 );
age = dateDiff('yyyy', birthDate, now());
writeoutput( age );
Note the different behavior between ColdFusion and Lucee.
testDate = now();
diffDate = dateAdd('d', 1, testDate);
writeOutput(testDate.diff('d', diffDate)); // this returns 1 on Lucee, and -1 on ColdFusion
Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.