DaysTilBirthday(birthdate)
Last updated February 12, 2002
Version: 1 | Requires: ColdFusion 5 | Library: DateLib
Description:
DaysTilBirthday returns the number of days until your next birthday. It should accept any date ColdFusion can parse, and will return an integer. If your birthday happens to be today, it will return zero.
Return Values:
Returns a numeric value.
Example:
My birthday is in <cfoutput>#DaysTilBirthday(my_birthday)#</cfoutput> day(s).
Parameters:
| Name | Description | Required |
|---|---|---|
| birthdate | Birthdate you want to find the number of days until. Accepts any valid date object. | Yes |
Full UDF Source:
<cfscript>
/**
* Returns number of days until your next birthday.
*
* @param birthdate Birthdate you want to find the number of days until. Accepts any valid date object.
* @return Returns a numeric value.
* @author Jason Fuller (jason@yomamma.com)
* @version 1, February 12, 2002
*/
function DaysTilBirthday(birthdate) {
var daysRemaining = "";
if (DateFormat(now(), "MMDD") GT DateFormat(birthdate, "MMDD"))
daysRemaining = Int(CreateDate(DatePart("yyyy", now() + 365), DatePart("m", birthdate), DatePart("d", birthdate)) - now() + 1);
else
daysRemaining = Int(CreateDate(DatePart("yyyy", now()), DatePart("m", birthdate), DatePart("d", birthdate)) - now() + 1);
Return daysRemaining;
}
</cfscript>
Search CFLib.org
Latest Additions
Dave Anderson added
iniToStruct
20 day(s) ago
Dave Anderson added
deDupeArray
20 day(s) ago
Richard added
dice
22 day(s) ago
Isaac Dealey added
getRelative
a while ago
Top Rated
backupDatabase
Rated 5.0, 22 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)
highlightAndCrop
Rated 5.0, 4 time(s)