17
How To: Have Fun with Birthdates! Beth Breisnes @bethbrains Consultant, Bigger Boat Consulting …and date formulas!

Fun with Date Functions, Formulas, and Birthdays

  • Upload
    bbrei

  • View
    323

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Fun with Date Functions, Formulas, and Birthdays

How To: Have Funwith Birthdates!

Beth Breisnes@bethbrainsConsultant, Bigger Boat Consulting

…and date formulas!

Page 2: Fun with Date Functions, Formulas, and Birthdays

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

Page 3: Fun with Date Functions, Formulas, and Birthdays

Who cares about birthdays anyway?

Page 4: Fun with Date Functions, Formulas, and Birthdays

Who cares about dates in general?

Page 5: Fun with Date Functions, Formulas, and Birthdays

• Datefunctions• Helpfulmathfunctions

• Calculatebirthdaythisyear• Calculatenextbirthday• Birthdaymonitoring• Calculateageinyears• Calculateageinmonths• Findlastdayofthemonthofagivendate• Calculatemembershipexpirydate

Agenda

Page 6: Fun with Date Functions, Formulas, and Birthdays

Unmanaged package atbit.ly/happybirthdaydf15package

Don’t bother taking notes…

Page 7: Fun with Date Functions, Formulas, and Birthdays

• 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

Page 8: Fun with Date Functions, Formulas, and Birthdays

• Function Argument Return Data Type

• MOD() 2 Numbers Number

• Returnstheremainderafteryoudividebyaspecificdivisor

• MOD(3,3)=0

• MOD(4,3)=1

• FLOOR() Number Number

• Roundsanumberdowntothenearestwholenumber

Math Functions

Page 9: Fun with Date Functions, Formulas, and Birthdays

WARNING!

DATE(YEAR(TODAY()), MONTH(Birthdate), DAY(Birthdate))

Calculate Birthday This Year… maybe…

Findthemonth/day

Putitinthisyear

1. Whatiftheirbirthdayhasalreadypassed?

2. Whatiftheywerebornonaleapday?

Page 10: Fun with Date Functions, Formulas, and Birthdays

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

Page 11: Fun with Date Functions, Formulas, and Birthdays

FLOOR( ( TODAY() - Birthdate ) / 365.2425 )Calculate Age based on Birthdate

Findnumberofdays

Divideby1year,includingLeapYearfraction

RounddownLEAP YEAR

APPROVEDWARNING!

Page 12: Fun with Date Functions, Formulas, and Birthdays

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

Page 13: Fun with Date Functions, Formulas, and Birthdays

((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

Page 14: Fun with Date Functions, Formulas, and Birthdays

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

Page 15: Fun with Date Functions, Formulas, and Birthdays

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

Page 17: Fun with Date Functions, Formulas, and Birthdays

Thank You