Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2004
    Posts
    10

    Question Unanswered: FormatDateTime with zero padding

    I need to format today's date (using the date function) with the inclusion of the zeros (01/08/2005, for example). There does not seem to be any option for this using the FormatDateTime() function. Does anyone know how to do this?
    I would be infinitely grateful for any help!!

  2. #2
    Join Date
    Nov 2004
    Posts
    5
    That one is very easy actually.

    The trick is done by seperating the day,mont and year values. (use split(datestring,"/") for that.

    Then add 100 to the value of the day (the 5th becomes 105) then convert it to string ( cStr(dayvalue) ) and then take the left two characters of the string making the dayvalue "05"

    Do the same with month and year

    example:

    datestr=right(cStr(day(date)+100)),2) & "/" & right(cStr(month(date)+100)),2) & "/" & year(date)

    In the above example you can replace the day(date) and month(date) with the array values from the split if the date is supplied as a text string.

    Kenneth Tan
    Webdeveloper
    Simac ICT
    The Netherlands

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •