Contents > CFML Reference > ColdFusion Functions > DatePart PreviousNext

DatePart

Extracts a part from a date value.

Part of a date, as an integer.

Date and time functions

DatePart("datepart", "date")

DateAdd, DateConvert

ColdFusion MX 6.1: Added the datepart character L or l to represent milliseconds.

Parameter

Description

datepart

String:

  • yyyy: Year
  • q: Quarter
  • m: Month
  • y: Day of year
  • d: Day
  • w: Weekday
  • ww: Week
  • h: Hour
  • n: Minute
  • s: Second
  • l: Millisecond

date

Date/time object, in the range 100 AD-9999 AD.

When passing a date/time object as a string, you must enclose it in quotation marks. Otherwise, it is interpreted as a numeric representation of a date/time object.

<!--- This example shows information available from DatePart --->
<cfset todayDate = Now()>
<h3>DatePart Example</h3>
<p>Today's date is <cfoutput>#todayDate#</cfoutput>.
<p>Using datepart, we extract an integer representing the dateparts from that value
<cfoutput>
<ul>
   <li>year: #DatePart("yyyy", todayDate)#
   <li>quarter: #DatePart("q", todayDate)#
   <li>month: #DatePart("m", todayDate)#
   <li>day of year: #DatePart("y", todayDate)#
   <li>day: #DatePart("d", todayDate)#
   <li>weekday: #DatePart("w", todayDate)#
   <li>week: #DatePart("ww", todayDate)#
   <li>hour: #DatePart("h", todayDate)#
   <li>minute: #DatePart("n", todayDate)#
   <li>second: #DatePart("s", todayDate)#
</ul>
</cfoutput>

Contents > CFML Reference > ColdFusion Functions > DatePart PreviousNext

ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/functi60.htm