FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour DateTime variables problem XHabour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
DateTime variables problem XHabour
Posted: Sun Jul 29, 2012 07:07 AM
I am using xHarbour version build 1.2.1 Intl. (SimpLex) (Rev. 9421).
I am getting a runtime error while comparing two DateTime variables ( valtype 'T' ). Same code is running fine with Harbour.

Example code:
Code (fw): Select all Collapse
function test()
   
   local t1, t2

   t1 := DateTime()
   t2 := t1 - 30
   // ok till now
   ? t1 > t2     // should print .T. and Harbour works well

return nil

With xHarbour, I get runtime error and this is the error.log
Code (fw): Select all Collapse
Application
===========
   Path and name: C:\TESTS\FWH905\Bin\x3.Exe (32 bits)
   Size: 2,232,320 bytes
   Compiler version: xHarbour build 1.2.1 Intl. (SimpLex) (Rev. 9421)
   FiveWin  Version: FWHX 12.06
   Windows version: 6.1, Build 7601 Service Pack 1

   Time from start: 0 hours 0 mins 1 secs 
   Error occurred at: 29-07-2012, 12:28:57
   Error description: Error BASE/1075  Argument error: >
   Args:
     [   1] = T   29-07-2012 12:28:57
     [   2] = T   29-06-2012 12:28:57

Is anyone using a later version of xharbour where this problem is solved?
Regards



G. N. Rao.

Hyderabad, India
Posts: 518
Joined: Fri Jun 29, 2012 12:49 PM
Re: DateTime variables problem XHabour
Posted: Sun Jul 29, 2012 12:48 PM

Hi,

With xHarbour 1.2.1 (Simplex) rev 9596 works perfect.

Are you using xHarbour.com?.

Maybe the Fivetech build is old.

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: DateTime variables problem XHabour
Posted: Sun Jul 29, 2012 05:25 PM

Rao

I worked with the xHarbour developers to fix the DateTime problem. xHarbour 9444 or greater has the valtype "T" fix.

https://groups.google.com/forum/?fromgr ... U8fSJVmpN0

Rick Lipkin

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: DateTime variables problem XHabour
Posted: Sun Jul 29, 2012 06:10 PM

Mr Elvira and Mr Rick

Thanks for the information. With the latest build of xHarbour the datetime math is okay.

Special thanks to Mr Rick for following up with xHarbour team and getting the issues fixed.

When xHarbour introduced datetime values with the same valtype 'D' then the date and datetime math was superb. Later Harbour introduced separate datatype 'T'. Following it up, xharbour too started dealing with date and datetime as separate datatypes 'D' and 'T'. Initially there were problems like the one I reported, which seem to be fixed now.

Some issues still remain:
? CDOW( DateTime() ) --> "Sunday" in Harbour. xHarbour raises runtime error
? CMONTH( DateTime() ) --> "July" in Harbour. xHarbour raises runtime error.

xHarbour expects only Date type as parameter for the above functions.
DOW() and MONTH() work well in both Harbour and xHarbour for DateTime values also. Wish xHarbour team fixes these functions also.

We need to convert datetime() values to date datatype and call the above functions.

Fortunately xHarbour provides TTOD( <datetime> ) --> <date>. Works well in xHarbour but raises runtime error in Harbour.

Before xHarbour introduced separate datatype 'T', date and datetime math was working seamlessly. For example we could write Date() + 0.25 yielding current 6:00 am. Now that is not possible. We need to convert Date() into a DateTime variable and then do the math. Then how do we convert Date() into a DateTime datatype? I could not find any readymade function. STOT( DTOS( <dDate> ) ) is working well in both (x)Harbours.

Regards



G. N. Rao.

Hyderabad, India
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: DateTime variables problem XHabour
Posted: Mon Jul 30, 2012 12:36 PM
Rao

One of our friends in the FWH forum suggested this function ( below ) to convert Valtype "T" to ValType "D".

One thing I do not like about valtype "T" is when you assign a variable to DateTime, you now get the entire string and all your forms where you had Date variables now show the DateTime.

I have just decided to convert my DateTime variables back to Valtype "D" so they appear correct in all my forms and the math and business rules remain the same.

Here is the Valtype conversion which I have enhanced somewhat.

Rick Lipkin

Code (fw): Select all Collapse
//--------------------------
Function TtoDate( tDate )

If empty( tDate)
   Return( ctod("00/00/00"))
Endif

If ValType( tDate ) = "D"
   Return(tDate )
Endif

Return( stod( substr( ttos( tDate ), 1, 8 ) ))
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: DateTime variables problem XHabour
Posted: Mon Jul 30, 2012 01:38 PM

Mr Rick

When using xharbour, we can use TTOD( <datetimevar> ) --> <dDateVar>.
And yes I am using "( stod( Left( ttos( tDate ), 8 ) ))" while working with Harbour (3.1.0 Rev 17222), because Harbour's TTOD( <t> ) function is raising a run-time error.

Regards



G. N. Rao.

Hyderabad, India
Posts: 35
Joined: Sun Aug 29, 2010 12:44 PM
Re: DateTime variables problem XHabour
Posted: Wed Aug 08, 2012 03:42 AM
nageswaragunupudi wrote:Mr Elvira and Mr Rick
Some issues still remain:
? CDOW( DateTime() ) --> "Sunday" in Harbour. xHarbour raises runtime error
? CMONTH( DateTime() ) --> "July" in Harbour. xHarbour raises runtime error.

xHarbour expects only Date type as parameter for the above functions.
DOW() and MONTH() work well in both Harbour and xHarbour for DateTime values also. Wish xHarbour team fixes these functions also.


Thank you for the report. CDOW() and CMONTH() have been updated now to accept DATETIME values.
Andi
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: DateTime variables problem XHabour
Posted: Thu Aug 09, 2012 06:16 PM
andijahja wrote:
nageswaragunupudi wrote:Mr Elvira and Mr Rick
Some issues still remain:
? CDOW( DateTime() ) --> "Sunday" in Harbour. xHarbour raises runtime error
? CMONTH( DateTime() ) --> "July" in Harbour. xHarbour raises runtime error.

xHarbour expects only Date type as parameter for the above functions.
DOW() and MONTH() work well in both Harbour and xHarbour for DateTime values also. Wish xHarbour team fixes these functions also.


Thank you for the report. CDOW() and CMONTH() have been updated now to accept DATETIME values.

Thank you very much.
Now its all working very well.
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion