FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Convertir variable de tipo "T" a caracter
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Convertir variable de tipo "T" a caracter
Posted: Tue Oct 08, 2013 08:55 PM
Buenas tardes para todos

Resulta que hago una consulta en ADO para saber la hora del servidor de la siguiente manera:

Code (fw): Select all Collapse
      oVar:="SELECT CURDATE(),CURTIME()"
      TRY
        oConsBO := CreateObject("ADODB.Recordset")
      CATCH oError
        MsgStop(oLamcla:mErnt,oLamcla:mErco)
        RETURN(.F.)
      END
      oConsBO:CursorLocation  := adUseClient //adUseServer
      oConsBO:LockType        := adLockOptimistic
      oConsBO:CursorType      := adOpenKeyset
      oConsBO:Source          := oVar
      oConsBO:ActiveConnection( oLamcla:oServer )
      TRY
        oConsBO:Open()
      CATCH oError
        MsgStop(oLamcla:mComa,mDato)
      END
      nRegistros := oConsBO:RecordCount()

      msginfo(nRegistros)

      IF nRegistros#0
        oConsBO:MoveFirst()
        fech:=dtos(oConsBO:Fields("CURDATE()"):Value)
        hora:=oConsBO:Fields("CURtime()"):Value
      ENDIF
      oConsBO:close()

      msginfo(fech)
      msginfo(valtype(hora))


Pero me sale un mensaje que no puede convertir la variable en carácter

Le coloque un valtype y me dice que es de tipo "T"

Como convierto el contenido de esa variable en carácter o al menos como puedo leerlo.

De antemano gracias
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: Convertir variable de tipo "T" a caracter
Posted: Tue Oct 08, 2013 09:28 PM

TtoC()
Converts a DateTime value to a character string in SET DATE and SET TIME format.
Syntax
TtoC( <dDateTime> ) --> cDateTimeString

Arguments
<dDateTime>
The parameter must be a value of data type Date or DateTime. Return
The return value is a character string formatted in the current SET DATE and SET TIME format.
Description
The function converts a DateTime value to a character string. The string is formatted according to the current SET DATE and SET TIME format.
Important: use TtoC() and its counterpart CtoT() with extreme care. The result of both functions depends on the current SET DATE, SET EPOCH and SET TIME settings.




TtoS()
Converts a Date value to a character string in YYYYMMDDhhmmss.ccc format.
Syntax
TtoS( <dDateTime>) --> cYYYYMMDDhhmmss.ccc

Arguments
<dDateTime>
The parameter must be a value of data type Date or DateTime. Return
The return value is a character string of 18 bytes in lenth formatted as "YYYYMMDDhhmmss.ccc".
Description
This function converts a Date value to a character string of 18 bytes length that is independent from the settings SET CENTURY, SET DATE, SET EPOCH, and SET TIME. Therefore, TtoS() and its counterpart StoT() are the recommended DateTime to Character string conversion functions, unless a DateTime value must be output in a country specific format.
When DateTime fields are combined with Character fields in an index expression, use TtoS() to concatenate the DateTime field with the Character field. This ensures that the Date field is sorted in chronological order.
Info
See also: DateTime(), DtoS(), SET CENTURY, SET DATE, SET EPOCH, StoD(), StoT(), TtoC()
Category: Conversion functions , Date and time , xHarbour extensions
Source: rtl\dateshb.c
LIB: xhb.lib
DLL: xhbdll.dll

Example
// The example demonstrates TtoS() return values and outlines
the effect of SET DATE and SET TIME for DateTime output.

PROCEDURE Main
LOCAL dDateTime := {ˆ 2007/04/26 16:31:24.789 }
LOCAL cDateTime := TtoS( dDateTime )

? dDateTime // result: 04/26/07 16:31:24.78
? cDateTime // result: 20070426163124.789

SET DATE TO ITALIAN
SET TIME FORMAT TO "hh:mm pm"

? dDateTime // result: 26-04-07 04:31 PM
? cDateTime // result: 20070426163124.789

? cDateTime := TtoS( {ˆ 0/0/9 } ) // result: 000000.000
? Len( cDateTime ) // result: 18
RETURN





CStr()
Converts a value to a character string.
Syntax
CStr( <xValue> ) --> cString

Arguments
<xValue>
This is a value of any data type. Return
The function returns a character string holding the converted value.
Description
Function CStr() accepts a value of any data type and returns a character string holding information about the value. This character string can be output to the screen or printer, and is of informational use only when <xValue> is a complex data type (Array, Code block, Hash or Object).
Info
Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)

Continue the discussion