FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Very Old Date problem
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Very Old Date problem
Posted: Mon Apr 25, 2016 12:19 PM
To All

This is a very old date problem .. in a date field with Century ON ( 4 digit date ) .. if you edit the last digit of the year as in these pictures .. and change from 6 to 7 .. as you can see you get an invalid date "04/25/0207" that if not caught, will load itself into a .dbf date field and cause all kinds of havoc with reports ..

Here is a very simple example:
Code (fw): Select all Collapse
// testdate.prg


#include "FiveWin.ch"

//----------------------------------------------------------------------------//

Function Main()

Local oDlg, oBtn, oDate, dDate,nYear

SET DELETED on
SET CENTURY on
SET 3DLOOK on

nYEAR := ( year( DATE() )-30 )
SET EPOCH to ( nYEAR )

dDate := date()


DEFINE DIALOG oDlg FROM 5, 5 TO 25, 40 TITLE "Testing Dates"

   @ 2, 2 GET oDate var dDate OF oDlg

     @ 4,10 BUTTON "&Quit" OF oDlg SIZE 40,12 ;
          ACTION oDlg:End()

   ACTIVATE DIALOG oDlg

return nil

// end


Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Very Old Date problem
Posted: Mon Apr 25, 2016 12:48 PM
Code (fw): Select all Collapse
// testdate.prg

#include "FiveWin.ch"

//----------------------------------------------------------------------------//

Function Main()

   Local oDlg, oBtn, oDate, dDate,nYear

   SET DATE AMERICAN
   SET DELETED ON
   SET CENTURY ON
   SET 3DLOOK ON

   nYEAR := ( year( DATE() )-30 )
   SET EPOCH TO ( nYEAR )
   // SET DATE FORMAT "DD.MM.YYYY"

   dDate := date()

   DEFINE DIALOG oDlg FROM 5, 5 TO 25, 40 TITLE "Testing Dates"

      @ 2, 2 GET oDate var dDate OF oDlg

      @ 4,10 BUTTON "&Quit" OF oDlg SIZE 40,12 ;
             ACTION oDlg:End()

   ACTIVATE DIALOG oDlg

return nil

// end


João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Very Old Date problem
Posted: Mon Apr 25, 2016 12:59 PM

João

SET DATE AMERICAN had no effect :(

Rick LIpkin

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Very Old Date problem
Posted: Mon Apr 25, 2016 01:23 PM
Harbour .and. xHarbour tests, ok.



Regards,
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Very Old Date problem
Posted: Mon Apr 25, 2016 01:24 PM
Code (fw): Select all Collapse
// testdate.prg

#include "FiveWin.ch"

//----------------------------------------------------------------------------//

Function Main()

   Local oDlg, oBtn, oDate, dDate,nYear

   /*
   SET DATE AMERICAN
   SET DELETED ON
   SET CENTURY ON
   SET 3DLOOK ON

   nYEAR := ( year( DATE() )-30 )
   SET EPOCH TO ( nYEAR )
   // SET DATE FORMAT "DD.MM.YYYY"
   */

   SET DATE AMERICAN
   SET EPOCH TO YEAR( DATE() ) - 30
   SET CENTURY ON
   SET SOFTSEEK OFF
   SET WRAP ON
   SETCANCEL( .F. )
   SET CONFIRM OFF
   SET DELETED ON
   SET ESCAPE OFF
   SET EXACT ON
   SET EXCLUSIVE OFF
   SET MULTIPLE OFF 

   dDate := date()

   // ? dDate

   DEFINE DIALOG oDlg FROM 5, 5 TO 25, 40 TITLE "Testing Dates"

   @ 2, 2 GET oDate var dDate PICTURE "@D 99/99/9999" OF oDlg UPDATE

   @ 4,10 BUTTON "&Quit" OF oDlg SIZE 40,12 ;
          ACTION oDlg:End()

   ACTIVATE DIALOG oDlg

return nil

// end


João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Very Old Date problem
Posted: Mon Apr 25, 2016 02:18 PM

João

Does not work .. remember .. all I want to do is place my cursor ( hi-lite ) on the last number 6 and change it to 7 .. the date resolved back to 04/25/0207.

Rick Lipkin

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Very Old Date problem
Posted: Mon Apr 25, 2016 02:39 PM
If I understood,

Code (fw): Select all Collapse
   oDate:bGotFocus = { || oDate:SetPos( 10 ), nil }


Regards,
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Very Old Date problem
Posted: Mon Apr 25, 2016 02:47 PM

If you change date format
SET DATE JAPAN
The problem is even more evident

Marco Boschi
info@marcoboschi.it
Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
Re: Very Old Date problem
Posted: Mon Apr 25, 2016 03:15 PM

Rick.
Yes, you 're right , but if you don't lights the last digit, the correct value is taken. However I think it is problem to be corrected , since many users fall into this error.

Francisco J. Alegría P.

Chinandega, Nicaragua.



Fwxh-MySql-TMySql
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Very Old Date problem
Posted: Mon Apr 25, 2016 03:47 PM

Francisco

I migrated almost all my .dbf's to Sql Server and I have been aware of this problem for some time .. I usually put a valid _DateCHk() function on my date fields to make sure this sort of thing doesn't happen .. .dbf does not care if you save a date like 04/25/0207, but Sql Server will throw up a run-time error breaking the application.

The reason this came back on my radar is that I am currently upgrading a huge app that is using dbf\cdx to Sql Server and I am dealing with lots of invalid dates that I am having to fix and account for.

Thanks for your confirmation.

RIik LIpkin

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Very Old Date problem
Posted: Tue Apr 26, 2016 09:00 PM

Rick,

I tried the code in your first message and it works correctly for me.

Using FW 16.02/xHarbour 1.2.3 under Windows 10.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Very Old Date problem
Posted: Tue Apr 26, 2016 10:16 PM

James

Put your cursor on the last number in the date field and then change the 6 to 7 and you will see what I mean ..

Rick Lipkin

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Very Old Date problem
Posted: Tue Apr 26, 2016 10:19 PM

Rick,

That is exactly what I did.

I don't seem to have your email address. Go to my website (goIntellitech.com) and find my address. Email me, then I will send a copy of my working EXE to you.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Very Old Date problem
Posted: Tue Apr 26, 2016 10:20 PM

I confirm the problem.
We need to find a solution

Regards



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Very Old Date problem
Posted: Tue Apr 26, 2016 10:31 PM

Rick,

Here it is working fine too.

I added this in your code:

Set( 29, .T. )

as in your screenshot the cursor is in insert mode

What FWH version are you using ?

regards, saludos

Antonio Linares
www.fivetechsoft.com