Date comparison odity 8.09 and xHarbour

Date comparison odity 8.09 and xHarbour

Postby Rick Lipkin » Tue Sep 30, 2008 9:25 pm

Just re-compiled a SQL FWH application and I am comparing two dates derived from a SQL recordset using this code snipit below ..

What I am doing is setting the two date variables to their respective fields in a Project recorset and the last indexed ascending record in a reporting recordset.

Then I make the date comparison to see it the two dates equal or have changed. If they do not equal .. nTscore always gets set to the value 8.

With prior versions of FWH\xHarbour ( using 8.09 for this example and matching xHarbour from FTDN ) .. the dates :

dLAST_START_DATE <> dSTART_DATE are equal when you send the values to msginfo .. but the comparison fails. In order to get this code functional again .. I had to change the date values to dtoc() and compare them again .. Just thinking that xHarbour may be pulling in the date\time into the string and in the raw form .. the time stamps are different causing the comparison to fail.

Just curious if any of our TOleAuto() SQL experts can confirm what I am seeing ..

Thanks
Rick Lipkin
SC Dept of Health, USA

Code: Select all  Expand view
//----------- code snipit

lLAST := .T.

   TRY
      oRsRpt:MoveLast()
   CATCH
      lLAST := .F.
      dSTART_DATE     := oRsProj:Fields("start_date"):Value
      dEND_DATE       := oRsProj:Fields("end_date"):Value
      nEST_BUDGET     := oRsProj:Fields("est_budget"):Value
   END TRY

   IF lLAST = .T.
      dSTART_DATE     := oRsRpt:Fields("start_date"):Value
      dEND_DATE       := oRsRpt:Fields("end_date"):Value
      nEST_BUDGET     := oRsRpt:Fields("est_budget"):Value
   ENDIF

   // local .. will be last known value //
   dLAST_START_DATE  := dSTART_DATE
   dLAST_END_DATE    := dEND_DATE
   nLAST_EST_BUDGET  := nEST_BUDGET

   // go to data entry here allow to edit or change baseline values from project

   REDEFINE GET oSTART_DATE  VAR dSTART_DATE ID 146 of  oUSERS   UPDATE

   REDEFINE GET oEND_DATE  VAR dEND_DATE  ID 147 of oUSERS
                        UPDATE
   REDEFINE GET oEST_BUDGET VAR nEST_BUDGET  ID 148 of oUSERS    UPDATE

do some radio buttons here then

_ChgBud( oBTN3, cMODE, dLAST_START_DATE, dLAST_END_DATE, nLAST_EST_BUDGET,oBTN6  )

......

Static Func _ChgBud( oBTN3, cMODE, dLAST_START_DATE, dLAST_END_DATE, nLAST_EST_BUDGET,oBTN6  )


// check if any baseline values have changed .. auto red on Add  //

   IF EMPTY( dLAST_START_DATE )
   ELSE
      IF dLAST_START_DATE <> dSTART_DATE  // <-- errors here when the values are the same .. perhaps now including date\time from SQL table ??
         nTSCORE := 8
      ENDIF
   ENDIF

   IF EMPTY( dLAST_END_DATE )
   ELSE
      IF dLAST_END_DATE <> dEND_DATE
         nTSCORE := 8
      ENDIF
   ENDIF

   IF EMPTY( nLAST_EST_BUDGET )
   ELSE
      IF nLAST_EST_BUDGET <> nEST_BUDGET
         nTSCORE := 8
      ENDIF
   ENDIF
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Postby Antonio Linares » Wed Oct 01, 2008 7:58 am

Rick,

Please do:

MsgInfo( dLAST_START_DATE )
MsgInfo( dSTART_DATE )

and lets see what value each one has
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Rick Lipkin » Wed Oct 01, 2008 1:34 pm

Antonio

I did what you suggest and that is how I discovered the problem .. Msginfo apparently formats the variable for a date before sending it to display.. stripping out the essense of what I am guessing is happening ..

I think xHarbour may including the time stamp when you create the variable as in dDate_start := oRs:Fields("date_start"):Value .. the actual value may be 10/01/2008 10:51 AM

If this is the case .. then something has recently changed .. if you send dDate_start to MsgInfo .. you will get 10/01/2008 .. and that is what I looked at when I origionally discovered this problem .. the msginfo dates were exactically the same.

In order to fix the code .. I had to to this dtoc( dDate_start ) and compare it to the other date dtoc(dLast_start_date )

Hope that makes sense ..

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Postby Antonio Linares » Wed Oct 01, 2008 2:09 pm

Rick,

MsgInfo() calls DTOC() to turn a date into a string before displaying it.

Anyhow, good to know that you solved it :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 70 guests