Solved

Sybase command doubt

Posted on 2012-03-12
4
630 Views
Last Modified: 2012-03-13
Hi Experts...

I have a sybase quesry as shown which gives the resultant as :315.
Can anyone explain how this result is achieved.

Query:
select ( ((datepart(hh,'5:28:31') * 60) + datepart(mi,'5:28:31'))/15)*15

Result:
315
Please help...
0
Comment
Question by:gaugeta
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 12

Expert Comment

by:Sharon Seth
ID: 37710255
datepart(hh,'5:28:31')   returns the hour part i.e 5
datepart(mi,'5:28:31')   returns the minute part , which is 28

hh and mi are predefined constants in sybase
0
 
LVL 14

Assisted Solution

by:Jan_Franek
Jan_Franek earned 250 total points
ID: 37710305
datepart(hh,'5:28:31') = 5
(datepart(hh,'5:28:31') * 60) = 300
datepart(mi,'5:28:31') = 28
((datepart(hh,'5:28:31') * 60) + datepart(mi,'5:28:31')) = 328
((datepart(hh,'5:28:31') * 60) + datepart(mi,'5:28:31'))/15 = 328/15 = 21 - this is little strange, but as both arguments are integer, the division result is also truncated to integer

and in the end 21 * 15 = 315
0
 

Author Comment

by:gaugeta
ID: 37710315
@sharonseth:Thanks for the reply.
Is select(datepart(mi,'5:28:31'))/15)*15 where the resultant i s1.8666 is it rounded off to 1 so the resultant is 300+15.
Please clarify.
0
 
LVL 12

Accepted Solution

by:
Sharon Seth earned 250 total points
ID: 37710464
That would be same as select ((300 + 28)/15)*15

328/15 = 21.866

Decimal part is dropped
so , 21 * 15 = 315
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question