You need to sign in to do that
Don't have an account?
tzuvy
Subtract 5 hours from a Date / Time field
Hi,
I'm creating a date / time formula field in which I would like to keep te time of another date time field and subtract five hours from it.
For example, in field A I would have "11/23/2010 9:03 PM" and in field B (the formula one I should see "11/23/2010 4:03 PM"
Is this possible?
Thanks
Tzuvy
Use this formula.
fieldA - (1/4.8)
Let me know if you find any issues.
All Answers
yes, thats possible.
fieldA - 5 should do the job for fieldB
Hey sorry, i misunderstood your question.
Use this formula.
fieldA - (1/4.8)
Let me know if you find any issues.
Thanks!!
It works perfectly.
Cheers
Tzuvy
Just in case anybody else was wondering (i.e. you need to subtract or add more or less than 5 hours) 1/4.8 = 5 hours because it is taking 1 day and dividing it by the quotient of 24hours / number of hours. 24 / 5 = 4.8 or 24/4 = 6 (1/6) . 4 hours is 1/6th of a day. 5 hours is 1/4.8th of a day.
Instead of (1/6) You have to use (DateTime - (1/6.0)) for 4 hrs subtraction
(DateTime - (1/8.0)) for 3 hrs subtraction
(DateTime - (1/12.0)) for 2 hrs subtraction
(DateTime - (1/24.0)) for 1 hrs subtraction
have a nice day!!
DateTime d = (System.now()- ((24/1440.0)/5.0)) will it work?
fieldA - (5/24)
A more universal formula to address positive and negative UTC offset: initialDateField + (<offset hours>/24). This should also allow you to adjust easily for those UTC offsets that have half-hour or 45-minute increments (additionally adjust by .5 or .75). Simply replace <offset hours> with your positive or negative offset hours. In this example initialDateField + (-5/24).
Keep in mind none of these examples account for changes within the year due to daylight savings time.