How do we manipulate DateTime objects in dataset's expression-based columns?
Michael Le
Thanks for the reply. However, you must have misundertood my question. What I was trying to do was to add an expression-based column in DataSet object which calculates a date based on another DateTime column. Specifically, I have a collumn named DateEnrolled. I want to add another column name ExpectedGradDate, which is equal to DateEnrolled + 180 (days). I've tried to put the following in the Expression property of the added column:1. DateEnrolled + 180 // did not work2. DateEnrolled.Add(180) // did not work either
Is there any way to work around this issue?
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.
I've tried to use SQL functions like Add() or DateDiff() but they didn't work.