Question : Convert DateTime to Float or another numeric value

is there any way to convert a datetime to a numeric value in an SQL-statement (using MS SQL 6.5)

e.g. When I use the statement
select convert (float,getdate())
it returns the following message:

Msg 529, Level 16, State 1
Explicit conversion from datatype 'datetime' to 'float'  is currently unimplemented.


In The Help, they also say it's not supported, but isn't there any way to do it???

thanx

Answer : Convert DateTime to Float or another numeric value

Here Goes its not pretty

In one line (sort of)

select datediff(dd,"30/Dec/1899",@date) + datediff(ss,dateadd(dd,datediff(dd,"30/Dec/1899",@date),"30/Dec/1899"),@date)/(24.0*60*60)

where @date is your date

or
begin
  declare @day integer
  declare @date datetime
  declare @sec integer
  select @date= "3/Aug/1975 12:45"
  select @day = datediff(dd,"30/Dec/1899",@date)
  select @sec = datediff(ss,dateadd(dd,@day,"30/Dec/1899"),@date)
  select @day+@sec/(24.0*60*60)
end

Which you can changed to a SP


Random Solutions  
 
programming4us programming4us