?
Solved

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

Posted on 2011-09-06
2
Medium Priority
?
366 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
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.
Suggested Courses

765 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