Results 1 to 6 of 6

Thread: FormatDateTime

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2001
    Location
    Vietnam
    Posts
    613

    FormatDateTime

    How can I use the FormatDateTime function (or whatever to get the result I want) to get the date in format dd/mm/yyyy

    Thanks.

  2. #2
    Fanatic Member VBKNIGHT's Avatar
    Join Date
    Oct 2000
    Location
    Port25
    Posts
    619
    you can use vbshortdate

    Response.Write FormatDateTime(Now, vbShortDate)

    Result is 01/20/02.

    If a post has helped you then Please Rate it!

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2001
    Location
    Vietnam
    Posts
    613
    But I only want in "dd/mm/yyyy" format. Can someone help?

  4. #4
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089

    hi

    I dont think there is any in-built function to give you the date in the manner you want.

    use this:

    Code:
    <%
    Function GiveMeDate()
    	dd = day(date)
    	mm = month(date)
    	yy = year(date)
    	GiveMeDate = dd & "/" & mm & "/" & yy
    End Function
    %>
    
    'Usage:
    
    <%=GiveMeDate%>

  5. #5
    Addicted Member
    Join Date
    Nov 2001
    Location
    Liverpool, England
    Posts
    155
    Code:
    Private Function DateFormat(inputDate)
    
    Dim arrDate
    Dim tempDay
    Dim tempMonth
    Dim tempYear
    
    'Format the input date as DD MONTHNAME YYYY (long date format)
      inputDate = FormatDateTime(inputDate, 1)
    
    'Split up this long date string into the arrDate array
      arrDate = Split(inputDate)
    
    'Assign temp vars values from the array
      tempDay = arrDate(0)    'Day as First array element
      tempYear = arrDate(2)   'Year as Third array element
    
    'Must derive the month number from full month name
      Select Case arrDate(1)
        Case "January"
          tempMonth = "01"
        Case "February"
          tempMonth = "02"
        Case "March"
          tempMonth = "03"
        Case "April"
          tempMonth = "04"
        Case "May"
          tempMonth = "05"
        Case "June"
          tempMonth = "06"
        Case "July"
          tempMonth = "07"
        Case "August"
          tempMonth = "08"
        Case "September"
          tempMonth = "09"
        Case "October"
          tempMonth = "10"
        Case "November"
          tempMonth = "11"
        Case "December"
          tempMonth = "12"
        End Select
    
        DateFormat = tempDay & "/" & tempMonth & "/" & tempYear
    
    End Function
    To use: DateFormat(yourDate)
    Last edited by sweevo; Mar 14th, 2002 at 05:53 AM.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2001
    Location
    Vietnam
    Posts
    613
    Thanks all.

Posting Permissions

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



Click Here to Expand Forum to Full Width