Solved

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

Posted on 2011-09-06
2
360 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 500 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

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…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

717 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