Date/Time Manipulation and Formatting
ColdFusion date-time variables can range from the year 100 Common Era (CE) to the year 9999, with a minimum resolution of one second. ColdFusion includes an extensive set of functions that can operate on date-time variables to manipulate them and extract the various components (year, month, hour).
DateTime objects in .NET can range from the year 1 CE to the year 9999, with a minimum resolution of 100 nanoseconds (one "tick"). Functionality for manipulating DateTime objects and extracting the various components is attached directly to the DateTime objects themselves, as Table 12 shows.
Table 12. Date Manipulation
CFML Visual Basic. NET
MonthAsString(Month(today))>
today)>
today, nextMonth)>
DateFormat(today, "full")>
Dim today As DateTime =
DateTime.Now
Dim thisYear As Integer =
today.Year
Dim thisMonthName As String =
today.ToString("MMMM")
Dim nextMonth As DateTime =
today.AddMonths(1)
Dim difference As Long =
DateDiff("d", today, nextMonth)
Dim dateString As String =
today.ToString("F")
One important difference to note is that, the equivalent of the DateFormat() function is the ToString() method of the DateTime object. Passing in a format string tells the DateTime object how to format the resulting string. For information about what format strings can be used, refer to Date and Time Format Strings.