Page 1 of 1

To Rick Lipkin for problem with ADO and BCC582

PostPosted: Wed Apr 04, 2012 7:48 pm
by jcaro
Hello Rick:

I am writing to see if you have any solution to the problem of dates "T" time, when consulting with ADO to MSSQL server.

My problem is that I do a query returns erroneous data types.

For example:
Code: Select all  Expand view



       ? oRs:Fields("FechaEmision"):Value               ==>  return blank fields  from  BD

       ?  Valtype( oRs:Fields("FechaEmision"):Value )      ==>  return  T            (   I think Time type  )

       ?  Dtoc( oRs:Fields("FechaEmision"):Value )         ==>  04-04-2012  ,  show how character type

 



I have read your queries, but not if you have any solution?

I am using BCC582 + the last build of xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 9445).

Any idea as you're doing ?

JC

Re: To Rick Lipkin for problem with ADO and BCC582

PostPosted: Wed Apr 04, 2012 8:47 pm
by Rick Lipkin
Juan

DateTime field types now return a valtype of "T" rather than "D" in xHarbour. I know this is now an inconvenience and when displaying your ADO date in your forms you do not get just a date ..

The fixes the xHarbour developers made was to keep the backward compatability in comparing values, adding and subtracting and writing the datetime back to the SQL table correctly.

Again, the biggest change is your DateTime values are a new valtype "T" and not considered "D" any longer.

The workaround was mentioned earlier in this forum and this user defined function takes a datetime back to valtype "D" ..

Code: Select all  Expand view

xCreateDate := oRsUser:Fields("CreateDate"):Value

? " "
? "xCreatedate from table after Get"
? xCreateDate
? xCreateDate := ttodate( xCreateDate )
? ValType( xCreateDate )
Wait

Return(nil)

//--------------------------
function ttodate( tDate )
return( stod( substr( ttos( tDate ), 1, 8 ) ))

 


Image

Re: To Rick Lipkin for problem with ADO and BCC582

PostPosted: Wed Apr 04, 2012 11:01 pm
by jcaro
Hello Rick:

Many thanks for your soon answers and time.

I expect another solution, but it's reassuring to know
string manipulations to dates he was doing,
were the best solution for the moment, I was doing.

JC

Re: To Rick Lipkin for problem with ADO and BCC582

PostPosted: Thu Apr 05, 2012 12:19 pm
by Rick Lipkin
Juan

It appears we must embrace the valtype "T" for Datetime... at least you can treat DateTime as you did valtype "D" as far as adding, subtracting values of datetime as well as datetime comparisons.. and then writing the datetime back to the SQL table.

The only inconvenience is how datetime shows in your current dialogs and forms. Build 9444 allows you to work with datetime as you did dates .. and that was the bug the developers recently fixed in xHarbour.

Rick

Re: To Rick Lipkin for problem with ADO and BCC582

PostPosted: Thu Apr 05, 2012 8:38 pm
by jcaro
Rick ,

OK, thanks for this new info.

JC