Solved

Date field

Posted on 2001-06-13
5
137 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
[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
  • 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…

734 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