Solved

Breaking down a date

Posted on 2001-09-17
4
148 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
Comment Utility
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
Comment Utility
You can use the Format$ function:

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

Expert Comment

by:rspahitz
Comment Utility
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
Comment Utility
This is exactly what I was looking for!

Thanks!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

772 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

13 Experts available now in Live!

Get 1:1 Help Now