all groups > sql server programming > march 2007 >
You're in the

sql server programming

group:

real to datetime - how to...?


Re: real to datetime - how to...? David Portas
3/5/2007 1:11:24 PM
sql server programming:
[quoted text, click to view]

DECLARE @r REAL;
SET @r = 23.613456;
SELECT DATEADD(MS,@r*3600000,'20070305');

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--
Re: real to datetime - how to...? Anith Sen
3/5/2007 2:54:35 PM
[quoted text, click to view]

What is 0,613456? Seconds or minutes?

--
Anith

Re: real to datetime - how to...? Raymond D'Anjou
3/5/2007 4:15:48 PM
Or for something a bit different:
select cast('20070305' as datetime) + @r*24

[quoted text, click to view]

Re: real to datetime - how to...? Raymond D'Anjou
3/5/2007 4:24:22 PM
.... I realize that these are both wrong are seeing his answer to Anith's
question.

[quoted text, click to view]

real to datetime - how to...? machina
3/5/2007 9:09:28 PM
Hi,

I would like to convert real data type to datetime type. Example:
I have a real data type which is: 23,613456 (23 hours and 0,613456). I
would like to have it in hh:mm:ss format. How to do this? Can I use
convert/cas function?

Thanks for help
Rgds
Mario

Re: real to datetime - how to...? machina
3/5/2007 10:18:15 PM
[quoted text, click to view]

Minutes and seconds.

Rgds
Mario

Re: real to datetime - how to...? Erland Sommarskog
3/5/2007 11:11:24 PM
machina (mm(at)home.pl) writes:
[quoted text, click to view]

And next time you feel compelled to ask the same question in two newsgroups,
please cross-post, so people don't waste time on answering things that
already have been answered. For the record, here is what I posted in
comp.databases.ms-sqlserver:

declare @d real
select @d = 23.613456
select @d = @d /24
select convert(char(8), convert(datetime, @d), 108)



--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
Re: real to datetime - how to...? machina
3/6/2007 7:49:39 PM
[quoted text, click to view]

Ok, I will :) Thanks for help.

Rgds
Mariusz

AddThis Social Bookmark Button