Solved

Convert MM/DD/YY to MMDDYY

Posted on 2010-09-14
4
998 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 500 total points
ID: 33676868
TheDate is your date string:
Replace(TheDate,"/","")
0
 
LVL 51

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 51

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

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

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

911 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

23 Experts available now in Live!

Get 1:1 Help Now