Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

datedifference

5 posts in General Discussion Last posting was on 2010-09-23 03:18:15.0Z
res Posted on 2010-09-22 08:11:26.0Z
Sender: 9f3.4c99b9b9.1804289383@sybase.com
From: res
Newsgroups: sybase.public.ase.general
Subject: datedifference
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4c99ba2e.9fc.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 22 Sep 2010 01:11:26 -0700
X-Trace: forums-1-dub 1285143086 10.22.241.41 (22 Sep 2010 01:11:26 -0700)
X-Original-Trace: 22 Sep 2010 01:11:26 -0700, 10.22.241.41
Lines: 8
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:29589
Article PK: 78823

Hi

Please help on how to find the time difference between
20.04.2010 / 12:00 and 20.04.2010 / 10:45
using datediff(hour) without any truncation?

Thanks
Res


Rob V [ Sybase ] Posted on 2010-09-22 08:18:16.0Z
From: "Rob V [ Sybase ]" <robv@DO.NOT.SPAM.sypron.nl.REMOVE.THIS.DECOY>
Reply-To: robv@DO.NOT.SPAM.sypron.nl.REMOVE.THIS.DECOY
Organization: Sypron BV / TeamSybase / Sybase
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.9) Gecko/20100915 Thunderbird/3.1.4
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: datedifference
References: <4c99ba2e.9fc.1681692777@sybase.com>
In-Reply-To: <4c99ba2e.9fc.1681692777@sybase.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4c99bbc8@forums-1-dub>
Date: 22 Sep 2010 01:18:16 -0700
X-Trace: forums-1-dub 1285143496 10.22.241.152 (22 Sep 2010 01:18:16 -0700)
X-Original-Trace: 22 Sep 2010 01:18:16 -0700, vip152.sybase.com
Lines: 39
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:29590
Article PK: 78824


On 22-Sep-2010 10:11, res wrote:
> Hi
>
> Please help on how to find the time difference between
> 20.04.2010 / 12:00 and 20.04.2010 / 10:45
> using datediff(hour) without any truncation?
>
> Thanks
> Res

datediff(<units>, ... , ... ) will always return a truncated integer
number of <units>, there's nothing you can do about that.
If you mean you want to have a result that says the diff is 1 hr 15 (or
1.25 hrs), then you need to first calc the diff in minutes, and then
divide (or modulo) that by 60. In other words, you have to convert the
minutes to hours yourself.
You can do that with datediff(mi, datetime1, datetime2), and convert
the resulting amount of minutes to hours.

HTH,

Rob V.
-----------------------------------------------------------------
Rob Verschoor

Certified Sybase Professional DBA for ASE 15.0/12.5/12.0/11.5/11.0
and Replication Server 15.0.1/12.5 // TeamSybase

Author of Sybase books (order online at www.sypron.nl/shop):
"Tips, Tricks& Recipes for Sybase ASE" (ASE 15 edition)
"The Complete Sybase ASE Quick Reference Guide"
"The Complete Sybase Replication Server Quick Reference Guide"

mailto:rob@YOUR.SPAM.sypron.nl.NOT.FOR.ME
http://www.sypron.nl
Sypron B.V., Amersfoort, The Netherlands
Chamber of Commerce 27138666
-----------------------------------------------------------------


Paul Dow <Paul.Dow Posted on 2010-09-22 16:27:35.0Z
From: Paul Dow <Paul.Dow@sybase_dot.com>
Organization: Sybase Engineering/iMET
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.9) Gecko/20100915 Lightning/1.0b2 Thunderbird/3.1.4
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: datedifference
References: <4c99bbc8@forums-1-dub> <4c99f01f.fbe.1681692777@sybase.com>
In-Reply-To: <4c99f01f.fbe.1681692777@sybase.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4c9a2e77@forums-1-dub>
Date: 22 Sep 2010 09:27:35 -0700
X-Trace: forums-1-dub 1285172855 10.22.241.152 (22 Sep 2010 09:27:35 -0700)
X-Original-Trace: 22 Sep 2010 09:27:35 -0700, vip152.sybase.com
Lines: 68
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:29595
Article PK: 78826

Res,

Is this what you are after ?


select str( datediff( ss, "20 Apr 2010 10:45", "20 Apr 2010 12:00" ) / (60.0 * 60.0), 6, 2 )


------
1.25

(1 row affected)

On 22/09/2010 13:01, res wrote:
> Hello
>
> Thanks for the immediate response.
> still the remaining .15 from the modulo - how can we
> represent as .25 hrs? division doesn't return the value nor
> the modulo.
>
> Res
>> On 22-Sep-2010 10:11, res wrote:
>>> Hi
>>>
>>> Please help on how to find the time difference between
>>> 20.04.2010 / 12:00 and 20.04.2010 / 10:45
>>> using datediff(hour) without any truncation?
>>>
>>> Thanks
>>> Res
>>
>> datediff(<units>, ... , ... ) will always return a
>> truncated integer number of<units>, there's nothing you
>> can do about that. If you mean you want to have a result
>> that says the diff is 1 hr 15 (or 1.25 hrs), then you
>> need to first calc the diff in minutes, and then divide
>> (or modulo) that by 60. In other words, you have to
>> convert the minutes to hours yourself.
>> You can do that with datediff(mi, datetime1, datetime2),
>> and convert the resulting amount of minutes to hours.
>>
>> HTH,
>>
>> Rob V.
>> ----------------------------------------------------------
>> ------- Rob Verschoor
>>
>> Certified Sybase Professional DBA for ASE
>> 15.0/12.5/12.0/11.5/11.0 and Replication Server
>> 15.0.1/12.5 // TeamSybase
>>
>> Author of Sybase books (order online at
>> www.sypron.nl/shop): "Tips, Tricks& Recipes for Sybase
>> ASE" (ASE 15 edition) "The Complete Sybase ASE Quick
>> Reference Guide" "The Complete Sybase Replication Server
>> Quick Reference Guide"
>>
>> mailto:rob@YOUR.SPAM.sypron.nl.NOT.FOR.ME
>> http://www.sypron.nl
>> Sypron B.V., Amersfoort, The Netherlands
>> Chamber of Commerce 27138666
>> ----------------------------------------------------------
>> -------
>>


res Posted on 2010-09-23 03:18:15.0Z
Sender: 2330.4c9ac5a8.1804289383@sybase.com
From: res
Newsgroups: sybase.public.ase.general
Subject: Re: datedifference
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4c9ac6f7.2349.1681692777@sybase.com>
References: <4c9a2e77@forums-1-dub>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 22 Sep 2010 20:18:15 -0700
X-Trace: forums-1-dub 1285211895 10.22.241.41 (22 Sep 2010 20:18:15 -0700)
X-Original-Trace: 22 Sep 2010 20:18:15 -0700, 10.22.241.41
Lines: 70
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:29597
Article PK: 78827

Yes, Thank You for your assistance dear Paul

> Res,
>
> Is this what you are after ?
>
>
> select str( datediff( ss, "20 Apr 2010 10:45", "20 Apr
> 2010 12:00" ) / (60.0 * 60.0), 6, 2 )
>
>
> ------
> 1.25
>
> (1 row affected)
>
>
>
> On 22/09/2010 13:01, res wrote:
> > Hello
> >
> > Thanks for the immediate response.
> > still the remaining .15 from the modulo - how can we
> > represent as .25 hrs? division doesn't return the value
> > nor the modulo.
> >
> > Res
> >> On 22-Sep-2010 10:11, res wrote:
> >>> Hi
> >>>
> >>> Please help on how to find the time difference between
> >>> 20.04.2010 / 12:00 and 20.04.2010 / 10:45
> >>> using datediff(hour) without any truncation?
> >>>
> >>> Thanks
> >>> Res
> >>
> >> datediff(<units>, ... , ... ) will always return a
> >> truncated integer number of<units>, there's nothing
> you >> can do about that. If you mean you want to have a
> result >> that says the diff is 1 hr 15 (or 1.25 hrs),
> then you >> need to first calc the diff in minutes, and
> then divide >> (or modulo) that by 60. In other words,
> you have to >> convert the minutes to hours yourself.
> >> You can do that with datediff(mi, datetime1, datetime2)
> , >> and convert the resulting amount of minutes to
> hours. >>
> >> HTH,
> >>
> >> Rob V.
> >>
> ----------------------------------------------------------
> >> ------- Rob Verschoor >>
> >> Certified Sybase Professional DBA for ASE
> >> 15.0/12.5/12.0/11.5/11.0 and Replication Server
> >> 15.0.1/12.5 // TeamSybase
> >>
> >> Author of Sybase books (order online at
> >> www.sypron.nl/shop): "Tips, Tricks& Recipes for
> Sybase >> ASE" (ASE 15 edition) "The Complete Sybase ASE
> Quick >> Reference Guide" "The Complete Sybase Replication
> Server >> Quick Reference Guide"
> >>
> >> mailto:rob@YOUR.SPAM.sypron.nl.NOT.FOR.ME
> >> http://www.sypron.nl
> >> Sypron B.V., Amersfoort, The Netherlands
> >> Chamber of Commerce 27138666
> >>
> ----------------------------------------------------------
> >> ------- >>
>