Solved

Date field

Posted on 2001-06-13
5
132 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

760 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

20 Experts available now in Live!

Get 1:1 Help Now