fun with date functions, formulas, and birthdays
TRANSCRIPT
How To: Have Funwith Birthdates!
Beth Breisnes@bethbrainsConsultant, Bigger Boat Consulting
…and date formulas!
Safe harbor statement under the Private Securities Litigation Reform Act of 1995:Thispresentationmaycontainforward-lookingstatementsthatinvolverisks,uncertainties,andassumptions.Ifanysuchuncertaintiesmaterializeorifanyoftheassumptionsprovesincorrect,theresultsofsalesforce.com,inc.coulddiffermateriallyfromtheresultsexpressedorimpliedbytheforward-lookingstatementswemake.Allstatementsotherthanstatementsofhistoricalfactcouldbedeemedforward-looking,includinganyprojectionsofproductorserviceavailability,subscribergrowth,earnings,revenues,orotherfinancialitemsandanystatementsregardingstrategiesorplansofmanagementforfutureoperations,statementsofbelief,anystatementsconcerningnew,planned,orupgradedservicesortechnologydevelopmentsandcustomercontractsoruseofourservices.Therisksanduncertaintiesreferredtoaboveinclude–butarenotlimitedto–risksassociatedwithdevelopinganddeliveringnewfunctionalityforourservice,newproductsandservices,ournewbusinessmodel,ourpastoperatinglosses,possiblefluctuationsinouroperatingresultsandrateofgrowth,interruptionsordelaysinourWebhosting,breachofoursecuritymeasures,theoutcomeofanylitigation,risksassociatedwithcompletedandanypossiblemergersandacquisitions,theimmaturemarketinwhichweoperate,our
relativelylimitedoperatinghistory,ourabilitytoexpand,retain,andmotivateouremployeesandmanageourgrowth,newreleasesofourserviceandsuccessfulcustomerdeployment,ourlimitedhistoryresellingnon-salesforce.comproducts,andutilizationandsellingtolargerenterprisecustomers.Furtherinformationonpotentialfactorsthatcouldaffectthefinancialresultsofsalesforce.com,inc.isincludedinourannualreportonForm10-KforthemostrecentfiscalyearandinourquarterlyreportonForm10-Qforthemostrecentfiscalquarter.ThesedocumentsandotherscontainingimportantdisclosuresareavailableontheSECFilingssectionoftheInvestorInformationsectionofourWebsite.Anyunreleasedservicesorfeaturesreferencedinthisorotherpresentations,pressreleasesorpublicstatementsarenotcurrentlyavailableandmaynotbedeliveredontimeoratall.Customerswhopurchaseourservicesshouldmakethepurchasedecisionsbaseduponfeaturesthatarecurrentlyavailable.Salesforce.com,inc.assumesnoobligationanddoesnotintendtoupdatetheseforward-lookingstatements.
Safe Harbor
Who cares about birthdays anyway?
Who cares about dates in general?
• Datefunctions• Helpfulmathfunctions
• Calculatebirthdaythisyear• Calculatenextbirthday• Birthdaymonitoring• Calculateageinyears• Calculateageinmonths• Findlastdayofthemonthofagivendate• Calculatemembershipexpirydate
Agenda
Unmanaged package atbit.ly/happybirthdaydf15package
Don’t bother taking notes…
• Function Argument Return Data Type
• DAY(Date__c) Date__c Number• MONTH(Date__c) Date__c Number• YEAR(Date__c) Date__c Number
• TODAY() Date• NOW() DateTime
• DATE(yyyy,mm,dd) 3 Numbers Date• DATEVALUE() DateTime Date
Date Functions
• Function Argument Return Data Type
• MOD() 2 Numbers Number
• Returnstheremainderafteryoudividebyaspecificdivisor
• MOD(3,3)=0
• MOD(4,3)=1
• FLOOR() Number Number
• Roundsanumberdowntothenearestwholenumber
Math Functions
WARNING!
DATE(YEAR(TODAY()), MONTH(Birthdate), DAY(Birthdate))
Calculate Birthday This Year… maybe…
Findthemonth/day
Putitinthisyear
1. Whatiftheirbirthdayhasalreadypassed?
2. Whatiftheywerebornonaleapday?
IF ( MONTH (Birthdate) = 2 && DAY (Birthdate) = 29, IF ( DATE ( YEAR ( TODAY() ), 1, 1 ) + 59 > TODAY(), DATE ( YEAR ( TODAY() ), 1, 1) + 59, DATE ( YEAR ( TODAY() )+1, 1, 1) + 59), IF (DATE (YEAR(TODAY()),MONTH(Birthdate),DAY(Birthdate)) > TODAY(), DATE(YEAR(TODAY()),MONTH(Birthdate),DAY(Birthdate)), DATE(YEAR(TODAY())+1,MONTH(Birthdate),DAY(Birthdate)) ) )
Calculate Next Birthday
LEAP YEAR
APPROVED
FLOOR( ( TODAY() - Birthdate ) / 365.2425 )Calculate Age based on Birthdate
Findnumberofdays
Divideby1year,includingLeapYearfraction
RounddownLEAP YEAR
APPROVEDWARNING!
YEAR(TODAY()) - YEAR(DOB__c) –
IF( OR (MONTH(TODAY()) < MONTH(DOB__c), AND( MONTH(TODAY()) == MONTH(DOB__c), DAY(TODAY()) < DAY(DOB__c) ) ), 1, 0)
A Better Way to Calculate Age based on Birthdate
((YEAR( TODAY())*12) + MONTH(TODAY()))- ((YEAR(Birthdate)*12) + MONTH(Birthdate))-
IF(DAY(Birthdate)>DAY(TODAY()), 1, 0 )
Calculate Age in Completed Months
LEAP YEAR
APPROVED
IF( MONTH( date ) = 12, DATE( YEAR( date ), 12, 31 ), DATE( YEAR( date ), MONTH ( date ) + 1, 1 ) - 1 )
Ifit’sDecember–thisyear,Dec31.
Otherwise–thisyear,findnextmonth’s1st,comeback1day.
Find the Last Day of the Month of a given Date
LEAP YEAR
APPROVED
IF ( MONTH (Join_Date__c) = 2 && DAY (Join_Date__c) = 29, Join_Date__c + 365, DATE( YEAR(Join_Date__c) + 1, MONTH(Join_Date__c), DAY (Join_Date__c)) -1)
Calculate Membership Expiry Date (add 1year-1day to a date)
LEAP YEAR
APPROVEDModified from Salesforce Saint
bit.ly/happybirthdaydf15package
Now go play!
Thank You