5

I have a decimal field in a SQL database that stores time only. Below is the data that is coming across and the end result I would like to display in a SSRS report. The solution could either be in the SQL query or maybe some type of SSRS formatting/expression.

Data      Desired Result
6.50      6:30:00 AM 
14.25     2:25:00 PM
17.75     5:45:00 PM
8.00      8:00:00 AM

I greatly appreciate any help with this.

3
  • 1
    select convert(smalldatetime, datediff(day, '1899-12-30T00:00:00', getdate()) + (6.50/24)) will get you to 2017-08-18 06:30:00
    – Jacob H
    Aug 16, 2017 at 17:16
  • Sorry for the dumb question, but if the solution gave the result of: 2017-08-18 06:29:59.970, then could I round that to 2017-08-18 06:30:00 in SSRS? If so, that would work.
    – jenhil34
    Aug 16, 2017 at 17:21
  • 1
    I just updated the comment. Smalldatetime might work.
    – Jacob H
    Aug 16, 2017 at 17:21

1 Answer 1

6

Alright this may not be pretty but it gives you the result you are looking for:

select convert(time(0), convert(smalldatetime, (6.50/24)))

Result:

06:30:00

Replace the 6.50 with your column name.

2
  • You are my superhero! Thank you it's perfect!
    – jenhil34
    Aug 16, 2017 at 17:28
  • No problem! Glad I could help
    – Jacob H
    Aug 16, 2017 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.