+ Start a Discussion
Terry JaegerTerry Jaeger 

Adding Date/Time Fields

Hello Everyone,

  I have a strange scenerio that I am not sure is possible.  What I am trying to do is take a date/time field and a number field and get another date time field.  So the use case is the client has a start date and time (date/time field) and a the duration (number field) the duration is the total hours worked.  The idea is to get the end time from the start date and time and the duration.  Now I if this does not work I may propose trying to use two date/time fields to get the duration.  If that is easier what would the formula be for the duration field.  Thank you for your help.  
Best Answer chosen by Terry Jaeger
AgiAgi
Hi,

you can try this:
create new formula field, return type Date/Time, and put in

start_date_and_time__c + (duration__c/24)


User-added image

All Answers

PeaceMakerPeaceMaker
Hi,

If you want to keep it simple , then go for two Date time fields . one for Start time and other one for End time.
Two Datetime field
1. Start date - datetime field
2. End date - datetime field

3. Create a new formula field with return type as text and use this below formula.
TEXT( FLOOR( (Et__c - st__c) ) ) & " days "
& TEXT( FLOOR( MOD( (Et__c - st__c) * 24, 24 ) ) ) & " hours "
& TEXT( ROUND( MOD( (Et__c - st__c) * 24 * 60, 60 ), 0 ) ) & " minutes"

Your output will look something like this..



User-added image




Here Et__c is end time and St__c is start time


Plz mark this as solution if it helps you :) Good luck Terry
AgiAgi
Hi,

you can try this:
create new formula field, return type Date/Time, and put in

start_date_and_time__c + (duration__c/24)


User-added image
This was selected as the best answer
Terry JaegerTerry Jaeger
Thank you PeaceMaker and Agi.  Both suggestions were great and worked perfectly.  Agi's suggestion solved the existing use case but its good to know PeaceMakers suggestion for future use cases.