Solved

converting dates to 1900+ rather than 2000+

Posted on 2002-04-12
7
229 Views
Last Modified: 2012-05-04
I am importing data from a text file that has mixture of dates in long format i.e. dd/mm/yyyy and short dates i.e. dd/mm/yy in one field. The field is a date of birth field, and it has people in it with date of birth before 1930. When i change the field to a date format, it changes there date of births to 2000+.
Can anyone tell me how to convert to dates before 1930.
0
Comment
Question by:Easty
  • 3
  • 2
  • 2
7 Comments
 
LVL 57
ID: 6936334
Which version of Access?  If it's 97 or later, there is nothing you can do about it in terms of changing the import behavior.

Couple of things then:
1. Change the input file.

2. Change the data after import with a query.

3. Import the file using a custom VBA procedure and modify the dates as they are read in.

 #3 is probably the best (but slightly more work - however you get complete control over the process), but I don't know if your importing into an existing table with data or not.  Also, I don't know if you can change the input file.

Jim.

0
 
LVL 18

Accepted Solution

by:
deighton earned 70 total points
ID: 6936369
After you import your file, run an update query, something like below. 2002 represents the latest year you can be born in.  If you have no children in your table, then you might want to change that to 1990 (for example)


UPDATE birthdates SET birthdates.dob = DateAdd("yyyy",-100,[dob])
WHERE Year([dob]) > 2002;



this finds dates that have converted to 2030 (say) and corrects them to 1930.
0
 

Author Comment

by:Easty
ID: 6936377
i am using access 2000.

changing the input file isn't really an option

The data is first imported into a table in access, then a  make table query is currently run on the data, this is the stage at which the dates are changed.

Is there any formatting you can do on the CDate function to import 2000 dates as 1900.
I notice that if i import the text file into excel first the dates are correctly changed, but i would prefer to bypass this stage as it creates an extra step and i'd like to automate the process as much as possible.

0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 57
ID: 6936402
<<i am using access 2000.>>

Ok.

<<changing the input file isn't really an option>>

Got it.

<<The data is first imported into a table in access, then a  make table query is currently run on the
data, this is the stage at which the dates are changed.

Is there any formatting you can do on the CDate function to import 2000 dates as 1900.
>>

  Sounds like your importing it as a text field.  If so that's good as you can run an update query to modify all the 2 digit dates <30 to 4 digits.  Then run your make table.


<<I notice that if i import the text file into excel first the dates are correctly changed, but i would
prefer to bypass this stage as it creates an extra step and i'd like to automate the process as much
as possible.>>

  You can do this in Access, but not witht he import wizard the way it is.  The rule for 2 digit years is that anything starting with 30 and up is assumed to be 2000, which you cannot change.  Excel is acting the opposite and assuming 1900.  Access used to be this way, but was changed with Access 97.  What are you guys doing in Excel with a birthdate of '01, which should be 2001 and not 1901?

Jim.
0
 
LVL 18

Expert Comment

by:deighton
ID: 6936489
How about my earlier idea of a running a query to knock 100 off any dates greater than 2002

UPDATE birthdates SET birthdates.dob = DateAdd("yyyy",-100,[dob])
WHERE Year([dob]) > year(now);
0
 
LVL 57
ID: 6936523
deighton,

 That won't work.  He needs to know which dates are 2 digit vs 4 so he can determine which need to be reduced

For example, if he imports:

01
2001

He would get:
2001
2001

 and it should be:

1901
2001
0
 

Author Comment

by:Easty
ID: 6936682
this seemed to be the best solution. Edited it slightly so it was in an if statement in the form of
iif([date of birth] >01/01/2002, dateadd("yyyy", -100, [date of birth]), [date of birth])

cheers.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

828 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