Total Computer Decisions
Pewaukee, WI  (262) 327-2700
Contact Us.

Home   |   Clients   |   Hosting   |   Terms   |   Services   |   Partnerships

Knowledge Base:   KB Home | File Access Control on XP Home | Basic Network Testing | Date Formatting | Web Design Tips

Date Formatting

I have witnessed individuals type 60-80 lines of code to produce "Today's Date" on a site, even more lines for Javascript and it doesn't even work during Daylight Savings or 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: Sunday, September 05, 2010

Or maybe numeric (short) format:
Actual code: <%=FormatDateTime(Now(), 2)%>
Output: 9/5/2010

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

 

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

The straight "Date"
Actual code: <%=Date()%>
Output: 9/5/2010

What week of the year is it? - Using "DatePart" this time, which returns integer results:
Actual code: <%=DatePart("WW", Now())%>
Output: 37
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


Computer support, computer, services, Pewaukee, Oconomowoc, waukesha, delafield, ASP development, ADO services, dynamic web pages, web sites, tcdweb, Total Computer Decisions, 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, Total Computer Decisions, 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, Total Computer Decisions, 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, Total Computer Decisions, 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