Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

t-sql convert a float to a datetime type field?

Posted on 2011-09-06
2
Medium Priority
?
372 Views
Last Modified: 2012-05-12
We have software inhouse where the developer has stored a date and time in a float field in the table.

It looks something like this: 40792.581238

Is there something like the convert function, in t-sql, that will allow me to convert this float value into some that I can convert into something like - mmddyyhhmmss?

What would the code look like - I have to take the field, convert it to a datetime value and then pass into my stored procedure.

Thanks much in advance.
0
Comment
Question by:samic400
[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 Comments
 
LVL 16

Accepted Solution

by:
brad2575 earned 2000 total points
ID: 36490765
select cast(40792.581238 as datetime)

if you want the format you can use this here to find specific format:

http://www.sql-server-helper.com/tips/date-formats.aspx

0
 
LVL 8

Expert Comment

by:stalhw
ID: 36490929
the cast option is a good one, no need to format the datetime to a string if you just want to pass it as a datetime parameter to a stored procedure...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

597 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