• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 378
  • Last Modified:

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

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.
1 Solution
select cast(40792.581238 as datetime)

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


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...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now