TCD Web & Networking Services
Chicago, Illinois  (708) 653-7738
Contact Us.

Home   |   Clients   |   Hosting   |   Terms   |   Services   |   Partnerships
Date Formatting 101:

Back to Knowledge Base Articles

I have watched people add 60-80 lines of code to produce "Today's Date" on a site, even more lines for Javascript and it doesn't even work on Leap years. If you're on an IIS server then you can use these simple tricks.

Samples of simple 1 line code, which formats dates. (ASP code is for IIS servers only.)

Long date format:
Actual code: <%=FormatDateTime(Now(), 1)%>
Output: Friday, November 21, 2008

Or maybe numeric (short) format:
Actual code: <%=FormatDateTime(Now(), 2)%>
Output: 11/21/2008

Do you need the current time only? (long format)
Actual code: <%=FormatDateTime(Now(), 3)%>
Output: 5:10:14 AM

 

Now lets look at the "Date" and "DatePart" Function:

The straight "Date"
Actual code: <%=Date()%>
Output: 11/21/2008

What week of the year is it? - Using "DatePart" this time, which returns integer results:
Actual code: <%=DatePart("WW", Now())%>
Output: 47
Options: "YYYY" Year; "Q" Quarter; "M" Month; "Y" Day Of Year; "D" Day; "W" WeekDay; "WW" Week Of Year; "H" Hour; "N" Minute; "S" Second

Back to Knowledge Base Articles


ASP development, ADO services, dynamic web pages, web sites, tcdweb, tcd web, web hosting, tim dempsey, web development, web sites, web sites, web hosts, email services, networking services, e-commerce, web applications, hosting, web clients, web partnerships, business webs, corporate web sites, professional webs, graphics, potography, video services, video editing, video marketing, avi files, annimation, web training, HTML development, tcdweb, tcd web, web hosting, tim dempsey, web development, web sites, web sites, web hosts, email services, networking services, e-commerce, web applications, hosting, web clients, web partnerships, business webs, corporate web sites, professional webs, graphics, potography, video services, video editing, video marketing, avi files, annimation, web training, HTML development, tcdweb, tcd web, web hosting, tim dempsey, web development, web sites, web sites, web hosts, email services, networking services, e-commerce, web applications, hosting, web clients, web partnerships, business webs, corporate web sites, professional webs, graphics, potography, video services, video editing, video marketing, avi files, annimation, web training, HTML development, tcdweb, tcd web, web hosting, tim dempsey, web development, web sites, web sites, web hosts, email services, networking services, e-commerce, web applications, hosting, web clients, web partnerships, business webs, corporate web sites, professional webs, graphics, potography, video services, video editing, video marketing, avi files, annimation, web training, HTML development