Solved

format date

Posted on 2003-11-04
4
1,099 Views
Last Modified: 2010-05-03
I have a date: 11/04/2006 and I want it to be formatted to MMYY, so it would = 1106, is there a formatting function that will do this?
0
Comment
Question by:Able22
  • 2
4 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 9680301
MsgBox Format(<yourDate>, "mmyy")
0
 

Author Comment

by:Able22
ID: 9680414
This is what I have in my code currently:


lexpire = Format(vexpire, "mmyy")   ' where vexpire = "10/31/2006"

lexpire gets set to 10/2/1902 , both vexpire and lexpire as Date field types

0
 
LVL 9

Accepted Solution

by:
Dang123 earned 50 total points
ID: 9680703
You must have lexpire defined as a date. Format is returning a variant (string). When you assign to the date variable it converts to a date based on what it has (1006). If you change lexpire to a string you will get the result you expect.

0
 

Author Comment

by:Able22
ID: 9680780
you mean lexpire has to be defined as a string, not a date..  That worked..  Thanks...
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in 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
DIR issue 7 54
VBA saving file message display 5 67
Visual Basic Excel Formatting error 4 107
How to set the sa password in a vb6 code for sql connection 9 55
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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

809 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