Solved

Date field

Posted on 2001-06-13
5
133 Views
Last Modified: 2010-05-02
I have imported over 20,000 records into an access database and the format on one of the date fields reads year/month/day.  Is there any way to code or format that field to read month/day/year?  

Can it be done by grabbing the first 4 digits (say "1999") and assigning those digits to a variable (say "y") and the next two digits to "m" and the last 2 digits to "d"?

Any help with this would be appreciated.

Mike
0
Comment
Question by:bauerm
  • 2
  • 2
5 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 6187101
just use Format(DateValue,"mm/dd/yyyy")

This will take any date field or valid date formatted string and convert it to a string in the appropriate format.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6187102
just use Format(DateValue,"mm/dd/yyyy")

This will take any date field or valid date formatted string and convert it to a string in the appropriate format.
0
 
LVL 4

Expert Comment

by:wileecoy
ID: 6187125
It depends on the format of the field in the database.

If the field is a number, I would do the following:

Assume MyDate is the result you need and TheDate is the field in the database now.

MyDate = mid(TheDate, 5,2) & "/" & right(TheDate,2) & "/" & left(TheDate,4)

That will produce MyMonth = MM/DD/YYYY

(I have to do this with our accounting software - this was their solution to the Y2K issue rather than actually have a date formatted field - Macola!)

Otherwise, if the field is a date format, just not the one you need, you can do the following:

MyDate = format(TheDate, "MM/DD/YYYY")

That should do it for you!

Hope that helps.

0
 
LVL 4

Accepted Solution

by:
wileecoy earned 100 total points
ID: 6187145
bauerm,

I forgot to clarify...

By an access field formatted as a number and used as a date in my example, the actual value of the field is:

20010613

This is YYYYMMDD.

As TimCottee explains, any value that represents a date format (i.e., 2001/06/13) can be changed to your preference with the Format function.

Good Luck!
0
 

Author Comment

by:bauerm
ID: 6187178
That worked, thanks for the help
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now