You need to sign in to do that
Don't have an account?

formula to return the hour from a date/time?
i'm stuck on this one. we want to be able to report on trending for cases/calls on a per hour basis. typically, one would do this by extracting the hour of the day from a date/time or time field and then summary reporting on that.
since the text functions for formula fields don't include a substring capability, i'm getting lost here.
does anyone have or know how to create a formula that will take a date/time and return the hour from it? preferably 24 hour scale vs. 12 hour scale...
thanks!
since the text functions for formula fields don't include a substring capability, i'm getting lost here.
does anyone have or know how to create a formula that will take a date/time and return the hour from it? preferably 24 hour scale vs. 12 hour scale...
thanks!
If I undestand your requirement correctly somthing like this should work:
MID(TEXT( DateTime__c ), 12, 2)
Just for further clarity the converted text DateTime looks like:
It does because the the conversion to text is always of the form:
Great - I have found that rather than 2 formulas you can combine the functions in one:
VALUE( MID(TEXT( DateTime__c ), 12, 2) )
This is a number formula field that gives the hour (at Z).
VALUE( MID(TEXT( DateTime__c ), 12, 2) ) -5
Adding the -5 makes the time zone adjustment.
I do not experience that:
Using VALUE( MID(TEXT( DateTime__c ), 12, 2) ) -5 to calculate local time. I guess I would if my offset was greater than 5, but it should only be what the actual offset from Z is.
Aha - you are right. Thanks for pointing it out. It would probably take some crazy IF statments to make the adjustment conditional.
Does this check out?
IF(VALUE( MID(TEXT( DateTime__c ), 12, 2) ) >= 5, VALUE( MID(TEXT( DateTime__c ), 12, 2) ) -5 , VALUE( MID(TEXT( DateTime__c ), 12, 2) ) +19 )
if((VALUE( MID(TEXT( CreatedDate ), 12, 2) ) - 4) <= 0, (VALUE( MID(TEXT( CreatedDate ), 12, 2) )) - 4 + 24, (VALUE( MID(TEXT( CreatedDate ), 12, 2) )) - 4 )
basically
if hour <= 0 subtract DLS and add 24, otherwise subtract DLS
the only thing that this doesn't take into account is that DLS changes THIS MONTH, so if a report using this field spans both time frames, there will be a little overlap. i'm ok with that though.
UTC for life :)
Cheers!