I did just do the math myself and it worked fine.
((Date_Time1 - Date_Time2) - (Days * 86400)) /60 /60

My concern was that HOURS() worked differently than MINUTES() or SECONDS()
Which worked as I expected.
The results and how they worked is inconsistent, which was why I posed the 
question.

Thanks,
Matt P.

-----Original Message-----
From: Action Request System discussion list(ARSList) 
[mailto:arslist@ARSLIST.ORG] On Behalf Of Grooms, Frederick W
Sent: Thursday, March 31, 2011 2:16 PM
To: arslist@ARSLIST.ORG
Subject: Re: HOURS function doesnt appear to work correctly

Except for the number of days ;)   i.e. (Jan 30, 2011 9:30 - Jan 1, 2011 7:30) 
/ 3600

Fred

-----Original Message-----
From: Action Request System discussion list(ARSList) 
[mailto:arslist@ARSLIST.ORG] On Behalf Of Misi Mladoniczky
Sent: Thursday, March 31, 2011 12:12 PM
To: arslist@ARSLIST.ORG
Subject: Re: HOURS function doesnt appear to work correctly

Well...

Why not just do an integer calculation instead of trying to fool the
HOURS-function?

($Date_Time2$ - $Date_Time1$) / 3600

It will allays give the difference correct.

        Best Regards - Misi, RRR AB, http://www.rrr.se

Products from RRR Scandinavia (Best R.O.I. Award at WWRUG10):
* RRR|License - Not enough Remedy licenses? Save money by optimizing.
* RRR|Log - Performance issues or elusive bugs? Analyze your Remedy logs.
Find these products, and many free tools and utilities, at http://rrr.se.

> I believe you can do it by adjusting for your time zone
>    HOURS("01/01/1970" + (Date_Time2 - Date_Time1))
>
> If you are in GMT it will add 0 to your results otherwise it will add the
> correct offset making the hours correct.
>
> Fred
>
> -----Original Message-----
> From: Action Request System discussion list(ARSList)
> [mailto:arslist@ARSLIST.ORG] On Behalf Of Misi Mladoniczky
> Sent: Thursday, March 31, 2011 10:16 AM
> To: arslist@ARSLIST.ORG
> Subject: Re: HOURS function doesnt appear to work correctly
>
> Hi,
>
> That is because the hours depend on your timezone.
>
> A diff of say 2 hours, would give you a date of 7200 seconds, which
> translates to January 1, 1970 02:00:00 GMT.
>
> The hours are 2 only if your client (or servers if it is a filter) is set
> for GMT.
>
>         Best Regards - Misi, RRR AB, http://www.rrr.se
>
>
> -----Original Message-----
> From: Action Request System discussion list(ARSList)
> [mailto:arslist@ARSLIST.ORG] On Behalf Of Misi Mladoniczky
> Sent: Thursday, March 31, 2011 9:48 AM
> To: arslist@ARSLIST.ORG
> Subject: Re: HOURS function doesnt appear to work correctly
>
> Hi,
>
> Yes it does, but you are not giving it a timestamp as argument. Instead
> you are giving it the difference in seconds between two timestamps...
>
>> -----Original Message-----
>> From: Action Request System discussion list(ARSList)
>> [mailto:arslist@ARSLIST.ORG] On Behalf Of Matthew Perrault
>> Sent: Thursday, March 31, 2011 9:04 AM
>> To: arslist@ARSLIST.ORG
>> Subject: HOURS function doesnt appear to work correctly
>>
>> All,
>> Found an oddity the other day.
>>
>> I was taking 2 Date/Time values and trying to break out days, hours,
>> minutes, and seconds.
>>
>> I used the datediff function to pull out the number of days different,
>> Then used the HOURS, MINUTES, and SECONDS functions.
>>
>> All except HOURS worked correctly.
>> HOURS(Date_Time2 - Date_Time1) = 0 (should have been 6)
>> MINUTES(Date_Time2 - Date_Time1) = 47 -->Correct
>> SECONDS(Date_Time2 - Date_Time1) = 23 -->Correct.
>>
>> I was able to get around it by just doing the math myself,
>> But I thought HOURS was supposed to return the number of hours in a Time
>> Stamp.
>> It's strange because it doesn't appear to be consistent in how the other
>> functions work.
>>
>> Was wondering if this was a defect or if I was just not using it
>> correctly.
>>
>> ARS 7.1 Patch 8
>> MS SQL Server 2005
>> Windows Server 2003
>>
>> Thanks,
>> Matt P.


Reply via email to