• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 630
  • Last Modified:

SQL Server DateTime to Float conversion

I am currently doing the following when in my SQL stored proc to convert a DateTime to a Float.

CAST([my_Date] AS FLOAT) + 2 as ConDate

This works fine except when I have a date such as '2010-11-11 00:00:00.000'.  Then the result is returned with no decimal places and when I convert that to a date in a .NET application it is translated as 2010-11-11 12:00:00.000 which isn't correct.

Anyone know if I can force the extra three decimal places?
0
briancostea
Asked:
briancostea
  • 2
1 Solution
 
cyberkiwiCommented:
CAST(my_date as decimal(20,10)) + 2
0
 
briancosteaAuthor Commented:
YIKES that was fast.  That solved the problem but unfortunately the Telerik control I am using still doesn't convert it properly.  Awarding points.
0
 
briancosteaAuthor Commented:
Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now