Name
DatePart
Synopsis
DatePart(datepart, date
)
Returns the specified part of a valid date/time object. Valid values
for the datepart
parameter are:
s
(second), n
(minute),
h
(hour), ww
(week),
w
(weekday), d
(day),
y
(day of year), m
(month),
q
(quarter), and yyyy
(year).
If date1
is greater than
date2
, a negative number is returned.
Examples:
<CFOUTPUT> The current time and date is #TimeFormat(Now( ),'hh:mm:ss tt')#, #DateFormat(Now( ),'mmmm dd, yyyy')# <P> <B>Second:</B> #DatePart('s', Now( ))#<BR> <B>Minute:</B> #DatePart('n', Now( ))#<BR> <B>Hour:</B> #DatePart('h', Now( ))#<BR> <B>Week:</B> #DatePart('ww', Now( ))#<BR> <B>Weekday:</B> #DatePart('w', Now( ))#<BR> <B>Day:</B> #DatePart('d', Now( ))#<BR> <B>Day of year:</B> #DatePart('y', Now( ))#<BR> <B>Month:</B> #DatePart('m', Now( ))#<BR> <B>Quarter:</B> #DatePart('q', Now( ))#<BR> <B>Year:</B> #DatePart('yyyy', Now( ))# </CFOUTPUT>
Get Programming ColdFusion now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.