[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

formatting for Y2K

Posted on 1998-08-08
6
Medium Priority
?
255 Views
Last Modified: 2010-04-30
I am currently using the Lost_Focus event in a textbox and formatting the date as:
Format(y2kcheck$, "m/d/yyyy"), but if the user enters 03/03/00 the output is 3/3/1900,
How can I change the code to make it 3/3/2000?
Code please...
0
Comment
Question by:dtucker
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 2

Expert Comment

by:percosolator
ID: 1468314
What version of VB are you using (VB5 SP3, here)

Tried the following in the immediate window:

?format("03/03/00","mm/dd/yyyy")
03/03/2000

Put it at 2000, for me.  Any other information?
0
 

Author Comment

by:dtucker
ID: 1468315
I am using vb4 16 bit.
I could even break down the date and replace 1900 with 2000 if there is not a FORMATing way to do it.
Code Please...
Thank you for your prompt response.
Dave
0
 
LVL 2

Expert Comment

by:percosolator
ID: 1468316
What we are seeing here is inherent behavior designed into the date datatype.

My understanding of how Microsoft decided to handle 2-digit years, was this.

any 2-digit year from 00 to 29 is considered 20th century (i.e. 2000, 2019, 2029)

any 2-digit year from 30 to 99 is considered 19th century (i.e. 1930, 1968, 1999)

(Tested them out here, and it worked as expected)

Try these examples (00,29,30,99) out and please post your results.  That will help us see what's going on to better solve your dilemma.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 6

Expert Comment

by:clifABB
ID: 1468317
Also, what database are you using?  Perhaps the database isn't Y2K compliant?
0
 

Author Comment

by:dtucker
ID: 1468318
My database is just a random file database, which isn't Y2K compliant.
if I type 3/3/00 I get 3/3/1900
if I type 3/3/30 I get 3/3/1930
So I have to find a way to check for the 00 in my date field and translate that to 2000, as well as 01 as 2001 etc.
Right now if someone types in 3/12/98 it returns 3/12/1998, so all is fine until the year 2000.
Any thought as how to do the check and conversion in vb4 16-bit?
0
 
LVL 2

Accepted Solution

by:
percosolator earned 200 total points
ID: 1468319
Here is some sample code that I tested and believe will help you with your problem.

Put this code and put it in a test project.  If you have any questions, please post them.

-------------------------------------------------

Option Explicit

Private Sub Form_Load()

    MsgBox FixDate(CDate("1/1/00"))
    MsgBox FixDate(CDate("1/1/01"))
    MsgBox FixDate(CDate("1/1/99"))
   
    MsgBox FixDate(CDate("3/3/29"))
    MsgBox FixDate(CDate("3/30/30"))
    MsgBox FixDate(CDate("2/3/68"))
End Sub
Private Function FixDate(Date_ As Date) As String

    Dim strYear As String, _
        strDay As String, _
        strMonth As String
   
   
    strYear = Format(Date_, "yyyy")
    strMonth = Format(Date_, "mm")
    strDay = Format(Date_, "dd")
   
    If (strYear < "1930") Then strYear = strYear + 100
   
    FixDate = Format(strMonth & "/" & strDay & "/" & strYear, "mm/dd/yyyy")
       
End Function

------------------------------------
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question