Results 1 to 11 of 11

Thread: Format

  1. #1
    chenko
    Guest

    Unhappy Format

    How can I format any date to dd/mm/yy format in ASP? it seams to have the Format() Function missing

  2. #2
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    hummm,

    you can use
    formatDateTime(yourDate,vbShortDate)

    but it is in

    mm/dd/yy


    for dd/mm/yy i don't know!!

  3. #3
    chenko
    Guest
    formatDateTime(yourDate,"dd/mm/yy") will probaly work then

    Cheers

  4. #4
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216
    Originally posted by chenko
    formatDateTime(yourDate,"dd/mm/yy") will probaly work then

    Cheers
    did it work for you?!

  5. #5
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    I believe formatdatatime requires a named format. In order to do 'dd/mm/yyyy' you have to change your shortdate format in the region settings of the server to match that, then use formatdatetime(date, vbShortDate)
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    monte96_@hotmail.com
    monte96@vbgarage.com


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  6. #6
    PWNettle
    Guest

    Two ways...

    1. Write a Dll in VB that wraps the Format() function and create an object from this Dll in your ASP code.

    2. Write your own custom date function in your ASP that uses the Day(), Month(), and Year() functions to put your date into the format you desire. For example:
    Code:
    <%
    Function FormatDateCustom(DateToFormat)
      Dim strReturn
      Dim strTemp
    
      '  Day.
      strTemp = Day(DateToFormat)
      If Len(strTemp) = 1 Then
        strTemp = "0" & strTemp
      End If
      strReturn = strTemp
      '  Month.
      strTemp = Month(DateToFormat)
      If Len(strTemp) = 1 Then
        strTemp = "0" & strTemp
      End If
      strReturn = strReturn & "/" & strTemp
      '  Year.
      strTemp = Mid(Year(DateToFormat), 3, 2)
      strReturn = strReturn & "/" & strTemp
      
      FormatDateCustom = strReturn
    End Function
    
    '  Which could be called like:
    Response.Write "<P>" & FormatDateCustom(Now) & "</P>" & vbcrlf
    %>
    Paul

  7. #7
    MadWorm
    Guest

    PWNettle is right, use a DLL

    I wrote one a while ago, here it is attached, just download it and register it.

    usage....
    Code:
    set o = server.createobject("aspformat.format")
    mystring = o.formatstring(now, "dd-mmm-yyyy hh:nn:ss")
    Attached Files Attached Files

  8. #8
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Re: PWNettle is right, use a DLL

    Originally posted by MadWorm
    I wrote one a while ago, here it is attached, just download it and register it.

    usage....
    Code:
    set o = server.createobject("aspformat.format")
    mystring = o.formatstring(now, "dd-mmm-yyyy hh:nn:ss")

    Ahem: I wrote that code today. Who do you think you are?

  9. #9
    MadWorm
    Guest
    Please forgive me, I had the same brainstorm May last year, see the date on the DLL, very useful, I've used it heaps.

  10. #10
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877

    Re: Re: PWNettle is right, use a DLL

    Originally posted by jesus4u



    Ahem: I wrote that code today. Who do you think you are?
    I am a bit lost here, am i the only one .

    I havent had a look at any one of your code, but looking at what you have posted, i have to say its a very common method. i myself has written very similar functions to format date and time which i reuse in my applications.
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

  11. #11
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Re: PWNettle is right, use a DLL

    Originally posted by MadWorm
    I wrote one a while ago, here it is attached, just download it and register it.

    usage....
    Code:
    set o = server.createobject("aspformat.format")
    mystring = o.formatstring(now, "dd-mmm-yyyy hh:nn:ss")
    Sorry to sound accusatory but the odds are great that you would post the exact same name for a dll that I did yesterday!



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