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>

Chaz Wish List
Tall Tip $5
Grande Tip $20
Venti Tip $39
Tip Jar Thanks
2004 Thanks
2005 Thanks
HUGE Tip -love site