Very Old Date problem

Very Old Date problem

Postby Rick Lipkin » 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: Select all  Expand view

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

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

Re: Very Old Date problem

Postby karinha » Mon Apr 25, 2016 12:48 pm

Code: Select all  Expand view

// 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
User avatar
karinha
 
Posts: 7814
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Very Old Date problem

Postby Rick Lipkin » Mon Apr 25, 2016 12:59 pm

João

SET DATE AMERICAN had no effect :(

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

Re: Very Old Date problem

Postby karinha » Mon Apr 25, 2016 1:23 pm

Harbour .and. xHarbour tests, ok.

Image

Regards,
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7814
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Very Old Date problem

Postby karinha » Mon Apr 25, 2016 1:24 pm

Code: Select all  Expand view

// 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
User avatar
karinha
 
Posts: 7814
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Very Old Date problem

Postby Rick Lipkin » Mon Apr 25, 2016 2: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
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Very Old Date problem

Postby karinha » Mon Apr 25, 2016 2:39 pm

If I understood,

Code: Select all  Expand view

   oDate:bGotFocus = { || oDate:SetPos( 10 ), nil }
 


Regards,
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7814
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Very Old Date problem

Postby MarcoBoschi » Mon Apr 25, 2016 2:47 pm

If you change date format
SET DATE JAPAN
The problem is even more evident
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Very Old Date problem

Postby FranciscoA » Mon Apr 25, 2016 3: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
User avatar
FranciscoA
 
Posts: 2158
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Very Old Date problem

Postby Rick Lipkin » Mon Apr 25, 2016 3: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
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Very Old Date problem

Postby James Bott » Tue Apr 26, 2016 9: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Very Old Date problem

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

Re: Very Old Date problem

Postby James Bott » 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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Very Old Date problem

Postby nageswaragunupudi » Tue Apr 26, 2016 10:20 pm

I confirm the problem.
We need to find a solution
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Very Old Date problem

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 76 guests