Solved

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

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to shrink a transaction log file down to a reasonable size.

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now