Page 1 of 2
Very Old Date problem
Posted:
Mon Apr 25, 2016 12:19 pm
by Rick Lipkin
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
Re: Very Old Date problem
Posted:
Mon Apr 25, 2016 12:48 pm
by karinha
- 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
Re: Very Old Date problem
Posted:
Mon Apr 25, 2016 12:59 pm
by Rick Lipkin
João
SET DATE AMERICAN had no effect
Rick LIpkin
Re: Very Old Date problem
Posted:
Mon Apr 25, 2016 1:23 pm
by karinha
Harbour .and. xHarbour tests, ok.
Regards,
Re: Very Old Date problem
Posted:
Mon Apr 25, 2016 1:24 pm
by karinha
- 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
Re: Very Old Date problem
Posted:
Mon Apr 25, 2016 2:18 pm
by Rick Lipkin
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
Re: Very Old Date problem
Posted:
Mon Apr 25, 2016 2:39 pm
by karinha
If I understood,
- Code: Select all Expand view
oDate:bGotFocus = { || oDate:SetPos( 10 ), nil }
Regards,
Re: Very Old Date problem
Posted:
Mon Apr 25, 2016 2:47 pm
by MarcoBoschi
If you change date format
SET DATE JAPAN
The problem is even more evident
Re: Very Old Date problem
Posted:
Mon Apr 25, 2016 3:15 pm
by FranciscoA
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.
Re: Very Old Date problem
Posted:
Mon Apr 25, 2016 3:47 pm
by Rick Lipkin
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
Re: Very Old Date problem
Posted:
Tue Apr 26, 2016 9:00 pm
by James Bott
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
Re: Very Old Date problem
Posted:
Tue Apr 26, 2016 10:16 pm
by Rick Lipkin
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
Re: Very Old Date problem
Posted:
Tue Apr 26, 2016 10:19 pm
by James Bott
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
Re: Very Old Date problem
Posted:
Tue Apr 26, 2016 10:20 pm
by nageswaragunupudi
I confirm the problem.
We need to find a solution
Re: Very Old Date problem
Posted:
Tue Apr 26, 2016 10:31 pm
by Antonio Linares
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 ?