Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL Server DateTime to Float conversion

Posted on 2010-11-11
3
Medium Priority
?
622 Views
Last Modified: 2012-05-10
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
Comment
Question by:briancostea
  • 2
3 Comments
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 2000 total points
ID: 34116752
CAST(my_date as decimal(20,10)) + 2
0
 

Author Comment

by:briancostea
ID: 34116795
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
 

Author Closing Comment

by:briancostea
ID: 34116800
Thanks!
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

782 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