Solved

Date field

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Input past end of file vbs script 9 92
change vba from autofit to 13.5 width? 4 29
How does CurrentUser work? 10 37
SQL VB connection works in one PC and doesn't in another 15 64
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…

770 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