niceLabel VBscript reformat date -
new both nicelabel , vbscript. have expiration date string requires leading zero's when necessary.
for example;
"2016-2-7" "2016-02-07" "2016-2-27" "2016-02-27"
i'm guessing best way to:
- determine number of digits (
n) in value (v) via string conversion , length method if n < 2: v = "0"+ v;
however cannot figure out how this.
any appreciated.
- extract month using
monthfunction (or day usingdayfunction). - prepend
0result. - use
rightfunction extract last 2 characters.
if month 2, prepend 0 give 02. taking 2 right-most characters result in 02.
if month 12, 012, , 2 right-most characters 12.
below example.
mydate = #2016-2-27# mymonth = right("0" & month(mydate), 2) myday = right("0" & day(mydate), 2) formatteddate = year(mydate) & "-" & mymonth & "-" & myday msgbox formatteddate
Comments
Post a Comment