Format date number to 2 digits: 01, 02, 03, ... 09, 10 etc


    Dec 17 2010 | 10:17 am
    I am using the [date] object to name recordings made in a Max patch according to the time and date they were recorded. Since, I am sorting these recordings in numeric order unfortunately the number 2 for example will show up after the number 11 even though it was recorded earlier. I need to reformat the number 2 to the number 02 instead. That way 02 sorts before 11 as it should! I tried [sprintf] and other text number formatting, but a zero on the front of a number always disappears! help please.
    here is an example patch:

    • Dec 17 2010 | 10:31 am
      if you had read the help file of sprintf you wuld have discovered the easy way to add leading zeros:
    • Dec 17 2010 | 12:32 pm
      Thanks pid! I noticed that this only works if you add a letter before the zero. That why it didn't work for me earlier.
      Anyway to remove the letter and keep the zero?
      I would like my dates to look clean without extra characters if possible.
      See edited pid patch:
    • Dec 17 2010 | 2:31 pm
      ah i see.
      [combine] then...