Re: call a function using ado

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



chieko (chieko@xxxxxxxxxxxxxxxxxxxxxxxxx) writes:
> Yes, you're correct. i was in a hurry so i copied the function from the
> excel vba.
>...

> returns datetime
> as
> begin
> declare @SecondsToAdd bigint, @MilliSecToAdd bigint
> declare @RetVal datetime
>
> set @RetVal = NULL
>
> set @SecondsToAdd = (@FtValue - 116444736000000000)/10000000
> set @MilliSecToAdd = (@FtValue - 116444736000000000)/10000 -
> (@SecondsToAdd * 1000)
>
> if (@SecondsToAdd >= -2147483648) and (@SecondsToAdd <= 2147483647) and
> (@MilliSecToAdd >= -2147483648) and (@MilliSecToAdd <= 2147483647)
> set @RetVal = dateadd(ms, @MilliSecToAdd, dateadd(ss, @SecondsToAdd,
> cast('1970-01-01 00:00:00.000' as datetime)))
>
> return @RetVal
> end


As I can see, the function performs no data access at all. Seems
very ineffectient to me to SQL Server for such a thing. Surely
you should be able to this in VBA?


--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx

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
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.



Relevant Pages

  • Re: trouble porting a trivially simple function - with declared variables
    ... CREATE FUNCTION my_max_market_date RETURNS datetime ... DECLARE @mmmd AS datetime; ... SQL Server comes with an extensive Online documentation, ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Real to datetime - how to...?
    ... would like to have it in hh:mm:ss format. ... The division with 24 is necessary, because a datetime value consists ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • RE: Problem with profiling datetime
    ... DateTime dt = cmd.ExecuteScalar; ... The resulting trace log item is as follow ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (microsoft.public.sqlserver.tools)
  • Re: stored proc bug with datetime variable
    ... @DATE_RANGE_START as datetime, ... declare @DATE_RANGE_START datetime ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: datetime
    ... > Your column is defined as datetime datatype and you have a default ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)