Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a setting to change the year of a date?

Status
Not open for further replies.

snoopy80

Technical User
Jun 27, 2001
106
Happy Holiday
I have a column that accept data as mm/dd/yy format. the problem happens only at this time of year. When user enter 01/05 and press enter it will automatically set to 1/5/2005, but what it really should be is 1/5/2006. I assume it gets the year from the system but is there a way for me to set it so it show 2006 instead?
Thanks for help
 


Hi,

Why do Dates and Times seem to be so much trouble? faq68-5827.

Skip,
[sub]
[glasses] [red]Be Advised![/red]
The band of elderly oriental musicians, known as Ground Cover, is, in reality...
Asian Jasmine![tongue][/sub]
 
Why Skip? Or rather...why are they so much trouble, Skip? Because, as your FAQ points out....they are NUMBERS. People persist in thinking of them as objects, as things.

It is the conceptual difference between:

It is a date. - a thing
It is. - a numeric value.

It is gonna take a looooonnnnnnngggggggg time (expressed as Julian of course....) to work that one out.

Gerry
 


"...but is there a way for me to set it so it show 2006 instead?"

Yes!

Instead of entering
[tt]
1/5
[/tt]
enter
[tt]
1/5/2006
[/tt]



Skip,
[sub]
[glasses] [red]Be Advised![/red]
The band of elderly oriental musicians, known as Ground Cover, is, in reality...
Asian Jasmine![tongue][/sub]
 
I understand where you're coming from. A lot of database design has to do with anticipating errors, and avoiding them. It's easy to tell people to enter the year, but if they find out they don't have to, they may take shortcuts.

I created a text box called "TestDate", and put this code in the AfterUpdate event. The only problem is, this won't let you add a date more than 30 days less than the current date. If that works, you can use it and it will add one year to any date that fits the criteria.


Private Sub TestDate_AfterUpdate()
Dim DateVal As Date

If TestDate < Date - 30 Then
DateVal = DateAdd("yyyy", 1, TestDate)

TestDate = DateVal
End If
End Sub

Another alternative is to have the date entered as text, and convert it to a date after you test it. If someone doesn't enter the year, you can pop up a message box asking them to correct it before you save the data.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top