Normal Topic Date elements 63 - 2063; 64 - 1964 (Read 1296 times)
jyellis
Full Member
Members
***
Offline


No personal text

Posts: 114
Location: Dallas-Fort Worth Area
Joined: May 19th, 2003
Date elements 63 - 2063; 64 - 1964
Apr 21st, 2004 at 1:51pm
Print Post Print Post  
I hope I haven't missed this on the forum.  But my data entry people just told me that when they enter a date:
12/31/63 or earlier it converts the date to: 12/31/2063 but if it is after 1/1/64 it conversts the date to: 1/1/1964

(We are using Win XP Pro but I checked the control panel/regional options date and it is set for 1930 to 2029)

  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Date elements 63 - 2063; 64 - 1964
Reply #1 - Apr 21st, 2004 at 8:51pm
Print Post Print Post  
Because we are client / server and cross platform, we use a standardized "Century Break" as opposed to using whatever is set on each and every client and server (some of which may not have a "control panel").

The formula we use:

Century = CurrentYear + CenturyBreak - TwoDigitYear - 100.

where CenturyBreak is set to 60.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
jyellis
Full Member
Members
***
Offline


No personal text

Posts: 114
Location: Dallas-Fort Worth Area
Joined: May 19th, 2003
Re: Date elements 63 - 2063; 64 - 1964
Reply #2 - Apr 21st, 2004 at 9:28pm
Print Post Print Post  
How would you fix this data entry problem?  I want them to be able to enter a two digit year like 4/4/59 and it return 4/4/1959

My guess would be an "element on exit" command, right?
  
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Date elements 63 - 2063; 64 - 1964
Reply #3 - Apr 21st, 2004 at 10:31pm
Print Post Print Post  
Can a few examples be made for the Century calculation?
I am obviously doing something wrong here. Embarrassed

Century = CurrentYear + CenturyBreak(60) - TwoDigitYear - 100.

Assume I entered 98 for 1998.
Century = 2004 + 60 = 2064 - 98 = 1966 - 100 = 1866 
So what does 1866 represent?

or I entered 65 for 1965:
Century = 2004 + 60 = 2064 - 65 = 1999 - 100 = 1899 
So what does 1899 represent?

or I entered 59 for 1959:
Century = 2004 + 60 = 2064 - 59 = 1905 - 100 = 1805 
So what does 1805 represent?

or I entered 12 for 2012:
Century = 2004 + 60 = 2064 - 12 = 2052 - 100 = 1952 
So what does 1952 represent?

Might be nice in the future to let the users define the cutoff period to change century.  This could be an Application Option with a built in default that matches the current method for backwards compatibility.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Date elements 63 - 2063; 64 - 1964
Reply #4 - Apr 22nd, 2004 at 12:15pm
Print Post Print Post  
Quote:
Might be nice in the future to let the users define the cutoff period to change century.  This could be an Application Option with a built in default that matches the current method for backwards compatibility.


Would if we could. They would have to set it system-wide on every client and server and every potential client and server.

I only summerized the math involved, to give a general sense of how it works. I thought it would obscure the point to add the code that reduces the value to a century instead of a year Here is the piece that will make your example math work (in C):

if((Century % 100) != 0)
{
       Century = Century - (Century % 100) + 100
}

where "%" is the modulo operator.

  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Date elements 63 - 2063; 64 - 1964
Reply #5 - Apr 22nd, 2004 at 12:29pm
Print Post Print Post  
Quote:
How would you fix this data entry problem?  I want them to be able to enter a two digit year like 4/4/59 and it return 4/4/1959

My guess would be an "element on exit" command, right? 


The answer I would recommend is: Use a four digit year whenever possible. The certainty and precision of actually specifying the year intended would've prevented the entire Y2K "panic".

If that is impossible, make it well known that the century "cutoff" is 60 plus current 2 digit year (1964).

If that is impossible, then - and only as a last resort. Apply programming.

In general, if I needed to have certainty about dates, I would insist that they be entered:

YYYY/MM./DD

And, if I were to apply programming to the problem, it would be to verify that that is the format. There is no other format that provides anything like the same level or precision and certainty. Even the four digit year format: MM/DD/YYYY is a problem in that most countries interpret that as DD/MM/YYYY. But then, many use dots or dashes, instead of slashes. Or don't use the english terms for the month names, etc....
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Date elements 63 - 2063; 64 - 1964
Reply #6 - Apr 22nd, 2004 at 2:20pm
Print Post Print Post  
Quote:
on Apr 21st, 2004, 6:28pm, jyellis wrote:
How would you fix this data entry problem?  I want them to be able to enter a two digit year like 4/4/59 and it return 4/4/1959

My guess would be an "element on exit" command, right? 
Yes, I agree, whatever you decide for format or programming content would be best applied on  "element on exit".  But I would also suggest that you make that formula a global function to be called when needed vs. entering all that  code into every date field "element on exit"

My experience with end users is that you can insist on certain data entry rules all you want, but if your program is not designed to force accuracy, you won't get it.  You also want the users to be able to work in the easiest and most natural process.

Here are two routines from some Q&A databases set up to control Y2K formats:
===========================
This routine warns that an early date has been entered,b ut allows operator to continue or go back and reenter.  This usually results from entering 2 digit years.

On Exit Program:
IF @YEAR(Date) < 1984 THEN {
    @PLAY("BEEP");
    @MSGBOX("    = = = CAUTION = = =    ",
    +@MID(Date,6,5) + "/" + @LEFT(Date,4)+ " MAY be using the wrong year?",
    "Enter years with 4 digits");
    }
===========================
This routine changes the date automatically, no notification to user, just makes it happen.  It just adds 100 years worth of days to the date calculated by the program.

On Exit Program:
If Date < "01/01/1984" Then {Date = Date + 36525}
============================
If you use a variation of these in Sesame, then you can also make the toggle date a global variable also.  rather then being "hard-coded" you could use a formula like Sesame is using to keep it 40 years from the current year, or maybe change it to only 20 years instead.
Also note that @PLAY("BEEP") may not work in Sesame on your particular system.
« Last Edit: Apr 22nd, 2004 at 3:21pm by Bob_Hansen »  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged