Results 1 to 2 of 2

Thread: Changing data types

  1. #1

    Thread Starter
    Addicted Member Skeen's Avatar
    Join Date
    Jul 2000
    Location
    Abingdon, Oxon
    Posts
    138

    Talking Changing data types

    Hi Y'all

    I'm having a bit of trouble converting data types using VBscript. I'm pulling numerical values from a database into a recordset, I then want to convert the values in the recordsets to inetgers so that I can perform mathematical opperations on them. Below are two lines of my code, the first one works, the second one gets an error saying:

    " Automation type not supported in VBscript "

    But it works for the first example - can anyone tell me where I'm going wrong?
    Heres the code:

    cmSQL = "SELECT PPM FROM Service_Details " _
    & " WHERE Customer_ID = '" & Custom_ID & "' "

    Set rsPRS = cnAcqAcc.Execute(cmSQL)
    rsPRS.MoveFirst
    PRS = int (rsPRS("PPM"))
    pprs = (PRS/100)
    Response.Write(pprs)

    This works fine, but the variable PPM is a whole number ie '10',
    Heres the next bit that dosn't work, the variable pulled from the table is a sumation of all the values in the column - but I can't see how it would make any difference.
    The SQL is ok, so it must be the 'int' function:

    sSQL = "SELECT SUM(DurationSecs) AS TotalTime " _
    & " FROM Opal_Data
    & " WHERE DialledNumber = '" & PRSselecta & "' " _
    & " AND StartDateTime >= " -
    & " (To_Date('" & Starter & "', 'dd/MM/yyyy')) " _
    & " AND EndDateTime <= " _
    & " (To_Date( '" & Ender & "', 'dd/MM/yyyy')) "

    Set rsTotTime = cnAcqAcc.Execute(sSQL)
    rsTotTime.MoveFirst
    TotTime = rsTotTime("TotalTime")
    ToTime = int (TotTime)
    ToTime2 = (ToTime/60)
    Response.Write(ToTime2)

    Any help would be greatly appreciated ( and would probably save my sanity!)

    Cheers 'n' beers

    Skeen
    "It wasn't the booze that made me snooze, It was the Gin that did me in!"

  2. #2
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    int() returns the integer portion of the expression.

    You want to use CInt() which converts an expression to an integer type.
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width