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:[email protected]] On Behalf Of Misi Mladoniczky
Sent: Thursday, March 31, 2011 10:16 AM
To: [email protected]
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:[email protected]] On Behalf Of Misi Mladoniczky
Sent: Thursday, March 31, 2011 9:48 AM
To: [email protected]
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:[email protected]] On Behalf Of Matthew Perrault
> Sent: Thursday, March 31, 2011 9:04 AM
> To: [email protected]
> 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