-Collapse +Expand
Access
Search Access Group:

Advanced
Access To/From
To/FromCODEGuides
Access Store
PRESTWOODSTORE

Prestwood eMagazine

January Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyMicrosoft Access BoardMS Access Interactive Topic   Print This     

Dates / DateSerial

Dates / DateSerial in MS Access Interactive topic (part of our Microsoft Access group).

Quick Search: DateSerial   Dates /   Dates / DateSerial  
KCRABBE
OTTAWA, ON, CANADA
I imported a .txt file into Access 2000.

One file has a Date of Birth (DOB) field. In the .txt file it is a text field with the structure: yyyymmdd

If I change the data field type to Date/Time when I import (through the specifications), I generate errors for every record.

If I leave the data field as text, import the file and then attempt to change the field type in the table structure, I get the same set of errors.

One person suggested using the DateSerial in a query and create a new field which is of the type date and breaks the date into its component parts separated with a - (2001-01-01). I used the code sent and indeed it did split the yyyymmdd into yyyy-mm-dd (format is great), only problem is that it changed the dates. . . 20010101 became 2008-10-18. My guess is that I am using the DateSerial function incorrectly in the query (well, that's pretty obvious).

Any suggestions? Or, can anyone tell me how to use the DateSerial function properly so that it translates yyyymmdd to yyyy-mm-dd and changes the field type from text to date?

Thanks, KC
 Posted 24 years ago (Thread Starter)
Comment Quote
About KCRABBE
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #6441, 2 replies
Thread Started 6/3/2002 8:37:00 AM
View Counter=1642
Location=OTTAWA, ON, CANADA  
Joined=26 years ago   MB Posts=32  
Most Recent Post
KCRABBE
OTTAWA, ON, CANADA
And now I can sleep tonight!

Thanks so much for your reply . . .take care, kc
 Posted 24 years ago (Thread Starter)
Comment Quote
About KCRABBE
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #6458 (Level 1.1)  Reply to 6441
Thread Started 6/3/2002 12:19:00 PM
View Counter=2
Location=OTTAWA, ON, CANADA  
Joined=26 years ago   MB Posts=32  
jdschram
MN
to change them to yyyy-mm-dd format from yyyymmdd you can do the following

assuming you have a table named Table1 and the text column named date2

SELECT Left([table1]![date2],4) & "-" & Left(Right([table1]![date2],4),2) & "-" & Right([table1]![date2],2) AS Expr1, table1.date2
FROM table1;

this is just manipulating the string takeing the left 4 characters (the year) and adding a - character then takinge the right 4 characters and taking the left 2 characters (the month) adding a - and then the right 2 charactars (the day)

its now just a matter of making this an update SQL statement instead of a select

HTH
JS
 Posted 24 years ago
Comment Quote
About jdschram
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #6452 (Level 1.2)  Reply to 6441
Reply Posted 6/3/2002 10:31:00 AM
Location=MN  
Joined=25 years ago   MB Posts=259  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1225A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #6441 Counter
1642
Since 4/2/2008
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2026 Prestwood IT Solutions.   [Security & Privacy]