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:

  1. determine number of digits (n) in value (v) via string conversion , length method
  2. if n < 2: v = "0"+ v;

however cannot figure out how this.

any appreciated.

  1. extract month using month function (or day using day function).
  2. prepend 0 result.
  3. use right function 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

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -