Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Format "mm/dd/yyy" doesn't work with 1/2/2002

Status
Not open for further replies.

stnkyminky

Programmer
Oct 15, 2001
476
0
0
US
I am using a masked edit box. I am using a mask as follows ##/##/####. When I return the date using formatdatetime(date, vbshortdate) or (date, "mm/dd/yyyy") I rcv 1/2/2002. The problem occurs, I think, because the month and day are not two characters. I changed the system date and the code works fine for dates with two char days and months. How do I work around this problem? Scott
Programmer Analyst
 
Use this statement to format your date:

Format$(Date, "mm/dd/yyyy")

Josh
 
I have noticed this problem in the past and it was due to the regional settings on the workstation. My short date format was M/D/YYYY. Once I changed the short date format
to MM/DD/YYYY then the VB date$ function worked properly.

To check your regional settings, go to Start Menu -> Settings - > Control Panel
and look for Regional.
 
The VB Maskeditbox assume that you input a text value not a date format so you have to input the complete data 01/02/2002 for it will not accept the value 1/2/2002 unless you put spaces _1/_2/2002 or after input put a validation in the maskeditbox
 
I have corrected the problem using format$. On the form load, I was trying to plug the current date into the msk edit box. This error would cause the program to exit. So ayh8disjob, I agree with your explanation. I applied MrEGuest's solution which will work in future applications. DonPablo's answer is a quick fix until I can reload the new program. Thanks again for the prompt responses.
Scott
Programmer Analyst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top