?
Solved

Convert MM/DD/YY to MMDDYY

Posted on 2010-09-14
4
Medium Priority
?
1,018 Views
Last Modified: 2012-05-10
I am relearning VBscript, for a specific job function, as I am most used to SQL and while I should know this I simply cannot figure out how to convert MM/DD/YY to a string: MMDDYY. I have attempted to use Cstr however I get a type mismatch.

Simply just trying to take a field (Denial Date) which is MM/DD/YY and convert it to DenailStr (MMDDYY)

Thank you in advance
0
Comment
Question by:mjfigur
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
VBClassicGuy earned 2000 total points
ID: 33676868
TheDate is your date string:
Replace(TheDate,"/","")
0
 
LVL 61

Expert Comment

by:HainKurt
ID: 33676908
if it is a date format,

dim newstr
newstr = month(mydate) & day(mydate) & (year(year) mod 100)

or

newstr = month(mydate) & day(mydate) & right(year(year),2)
0
 
LVL 61

Expert Comment

by:HainKurt
ID: 33676937
or use this
dim newstr
dim mydate
mydate = now()

newstr = right("0"& month(mydate),2) & right("0" & day(mydate),2) & (year(mydate) mod 100)
WScript.Echo newstr
newstr = right("0"& month(mydate),2) & right("0" & day(mydate),2) & right(year(mydate),2)
WScript.Echo newstr

Open in new window

0
 
LVL 13

Expert Comment

by:game-master
ID: 33678201


good morning!

try something like this..


dim strDate

strDate = format(yourDateHere, "MMDDYY")


game-master
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month14 days, 21 hours left to enroll

839 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