Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21379

Changing a String for Certain Dates

$
0
0
Hi all,

I am new to VB6

My question is, I have a date in the from of MDDYYYY... I need it to be in the from o f YYMMDD.

My program works for months that have two integers (10, 11, and 12)...but does not work for months with just one integer (1, 2, 3, 4, 5, 6, 7, 8, 9) and the reason for this, is because I need to append a 0 to the beginning for those months...

How do I add a 0 to the months that are represented with one integer and not add it to the months that are represented with two integers?

Thanks in advance
Code:

    thedate = MonthView1.Value    ' Grabs date from the calender (in the form mddyyyy)
    month = Mid(thedate, 1, 1)      ' define the month
    day = Mid(thedate, 2, 2)          ' define the day
    year = Mid(thedate, 4, 4)          ' define the year
    mod_year = Mid(year, 3, 2)      ' shorten the year from yyyy to yy           
    mod_date= mod_year & month & day


Viewing all articles
Browse latest Browse all 21379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>