Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll

my Blog
[prev. Lesson]  Format: Numbers #2
     [next Lesson]  Date/Time on ASP Pages by Tony Arguelles

Format Dates by Charles Carroll

The built-in date functions (described in next paragraph) are pretty lame. The holy grail of data formatting is at:
http://www.4guysfromrolla.com/webtech/112098-2.shtml

http://www.learnasp.com/iishelp/VBScript/htm/vbs109.htm are the official online docs for the FormatDateTime function. The easiest way to demonstrate formatting dates is just have some sample code that tries every permutation of the command.

   filename=/learn/test/formatdates.asp

<Test Script Below>


<html><head>
<title>formatdates.asp</title>
</head><body bgcolor="#FFFFFF"><html>
<%'My ASP program that formats dates
response.write "<hr>"
for counter=0 to 4
    currentdate=now()
    response.write "today is..." & "<br>"
    response.write currentdate & "<P>"
    select case counter
    case 0
        whichformat="vbgeneraldate"
    case 1
        whichformat="vblongdate"
    case 2
        whichformat="vbshortdate"
    case 3
        whichformat="vblongtime"
    case 4
        whichformat="vbshorttime"
    end select
    response.write "FormatDate(now()," & whichformat & ")="
    response.write Formatdatetime(currentdate,counter) & "<P><HR>"
next%>
</body></html>

There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too. a $5 tip buys him lunch at McDonalds, a $20 tip buys his kid Hitoshi a new computer game, a $39 tip buys his daughter Michiko a few nice outfits. See our donor list.