How to calculate hour ranges using apex in Salesforce?

How to calculate hour ranges using apex in Salesforce?

Sample Trigger:


trigger MemberSample on Member__c (before insert, before update) {

    for ( Member__c mem : trigger.New ) {

       
Double var = Math.Floor(( Double.valueOf( mem.End__c.getTime() ) –
Double.valueOf(mem.Start__c.getTime() ) ) / (1000.0*60.0*60.0));
        mem.Description__c = String.valueOf( var );

    }

Leave a Reply