Solved

Breaking down a date

Posted on 2001-09-17
4
149 Views
Last Modified: 2010-05-02
I have a program that asks a user for a date.  I take the input and make sure it's valid and then I convert it using CDate into the MM/DD/YYYY format.

However, the system I am writing this program for requires the date to be in the MMDDYY format.  How can I cut out the proper fields from the MM/DD/YYYY to get it into the MMDDYY format?
0
Comment
Question by:ahelgeson
4 Comments
 
LVL 1

Accepted Solution

by:
ripnasty earned 100 total points
ID: 6488335
Use the Format function

strDate = Format (yourdatefield, "mmddyy")

i.e. You want to format the current date

strDate = Format(Now(), "mmddyy")
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 6488336
You can use the Format$ function:

NewDate = Format$(OldDate,"MMDDYY")
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6488342
First, I'd recommend using a date-picker function so that you don't have to validate the date (since it can be in many different formats.)

Once you have a date in date format (CDate will do that), you can use Month(TheDate), Day(TheDate), Year(TheDate), then tack these pieces together.

Alternately, you can convert the date to a string, then extract the pieces:

left$(MyDate,2) & mid$(MyDate, 4,2) & right$(MyDate,2)
0
 

Author Comment

by:ahelgeson
ID: 6488350
This is exactly what I was looking for!

Thanks!
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

Suggested Solutions

Title # Comments Views Activity
Access 2016 VB code 9 103
Restricting text box entry from \/:?<>"| 9 76
passing a value with stream reader AFTER a ";" 3 58
Problem to With line 4 42
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

920 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

16 Experts available now in Live!

Get 1:1 Help Now