DateTime variables problem XHabour

Post Reply
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

DateTime variables problem XHabour

Post by nageswaragunupudi »

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: Select all


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: Select all

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
elvira
Posts: 462
Joined: Fri Jun 29, 2012 12:49 pm

Re: DateTime variables problem XHabour

Post by elvira »

Hi,

With xHarbour 1.2.1 (Simplex) rev 9596 works perfect.

Are you using xHarbour.com?.

Maybe the Fivetech build is old.
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: DateTime variables problem XHabour

Post by Rick Lipkin »

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
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: DateTime variables problem XHabour

Post by nageswaragunupudi »

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
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: DateTime variables problem XHabour

Post by Rick Lipkin »

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: Select all

//--------------------------
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 ) ))

 
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: DateTime variables problem XHabour

Post by nageswaragunupudi »

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
User avatar
andijahja
Posts: 35
Joined: Sun Aug 29, 2010 12:44 pm

Re: DateTime variables problem XHabour

Post by andijahja »

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
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: DateTime variables problem XHabour

Post by nageswaragunupudi »

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
Post Reply