Other 2: DateTime

<< Click to Display Table of Contents >>

Navigation:  Examples > Other samples >

Other 2: DateTime

Previous pageReturn to chapter overviewNext page

 The sample below shows how you can use the AdoDateTimeasDate() function to get date results or datetime results from Vo2Ado:

 

FUNCTION Start

 // this sample shows how to use the AdoServer object

 LOCAL oConn AS AdoCOnnection

 LOCAL oRS AS AdoRecordSet

 LOCAL strCnn AS STRING

 LOCAL oCons AS Console

 SET DATE Ansi

 oCOns := COnsole{}

 strCnn := "Provider= SQLOLEDB;Initial Catalog=pubs; Data Source=(local);uid=sa;pwd=;"

 // Set the default connection for better error reports

 oCOnn := AdoConnection{}

 AdoSetConnection(oConn)

 oConn:CursorLocation := AdUseClient

 oConn:Open(strCnn,NIL,NIL,NIL)

 // Open a recordset USING a client Side, KeySet cursor

 // Now set the AdoDateTimeAsDate() to FALSE

 oCOns:WriteLine("Show Date/Time values")

 AdoDateTimeAsDate(FALSE)

 oRs := AdoRecordSet{}

 oRs:Open("employee",oConn,adOpenKeySet, adLockOptimistic,adCmdTable)

 DO WHILE ! oRs:EOF

 IF oRs:[Collect,"Hire_Date"]:DATEVal < 1990.01.01

 oCOns:WriteLine(AsString(oRs:[Collect,1])+' '+;

 AsString(oRs:[Collect,"Hire_Date"]))

 ENDIF

 oRs:MoveNext()

 ENDDO

 oCons:Write("Press Enter")

 oCOns:Read()

 // Now set the AdoDateTimeAsDate() to TRUE

 oCOns:WriteLine("Show only Date values")

 AdoDateTimeAsDate(TRUE)

 oRs:MoveFirst()

 DO WHILE ! oRs:EOF

 IF oRs:[Collect,"Hire_Date"]< 1990.01.01

 oCOns:WriteLine(AsString(oRs:[Collect,1])+' '+ ;

 AsString(oRs:[Collect,"Hire_Date"]))

 ENDIF

 oRs:MoveNext()

 ENDDO

 oCons:Write("Press Enter")

 oCOns:Read()