DATE FORMAT

Results 1 to 2 of 2

Thread: DATE FORMAT

  1. #1
    Join Date
    Dec 1969
    Posts
    50

    Default DATE FORMAT

    I am pulling a date from a database and want to format it before displaying it. For example, the date in the database is 1/1/99 and I want to display it as 01/01/99. How can I do this?

  2. #2
    Join Date
    Dec 1969
    Posts
    1,671

    Default RE: DATE FORMAT

    Here is a little Function that will do it for you..<BR>Just call it the PadDate(YourDate). The function does not check for a valid date, so besure YourDate is valid first.<BR>&#060;%<BR>Function PadDate(OriginalDate)<BR> OriginalDay = DatePart("d", OriginalDate)<BR> OriginalMonth = DatePart("m", OriginalDate)<BR> NewYear = Right(DatePart("yyyy", OriginalDate), 2)<BR> <BR> If OriginalDay &#060;= 9 Then<BR> NewDay = "0" & OriginalDay<BR> Else<BR> NewDay = OriginalDay<BR> End If<BR> <BR> If OriginalMonth &#060;= 9 Then<BR> NewMonth = "0" & OriginalMonth<BR> Else<BR> NewMonth = OriginalMonth<BR> End If<BR> <BR> PadDate = NewMonth & "/" & NewDay & "/" & NewYear<BR>End Function<BR>%&#062;<BR>

Posting Permissions

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