Resolve differences between ABL and .NET date and time implementations
- Last Updated: March 30, 2020
- 1 minute read
- OpenEdge
- Version 12.2
- Documentation
Resolve differences between ABL and .NET date and time implementations
An ABL DATE field can have
its initial value set to the ABL TODAY built-in
function, which returns the current date. Similarly, an ABL DATETIME or DATETIME-TZ field
can have its initial value set to the ABL NOW built-in
function, which returns the current date and time. When you create
a new record for a temp-table in ABL that contains fields with these
data types, and these fields are defined as initialized with the corresponding
built-in functions, they are initialized to the date or date and time
(respectively) when the record is created.
However, .NET does
not provide exactly the same capability for the corresponding ADO.NET DataColumn
of type System.DateTime. The System.Data.DataColumn.DefaultValue property
sets a specific value for an object (the DataColumn). So, for a DateTime DataColumn,
you must set a specific (and static) date or date and time.
To
work around this limitation, you can programmatically set the value
for any ADO.NET DataColumn of type System.DateTime using
two .NET properties that correspond to the ABL TODAY and NOW built-in
functions, thus:
-
The
System.DataTime.Todayproperty returns aDateTimeinstance initialized with the current date. -
The
System.DataTime.Nowproperty returns aDateTimeinstance initialized with the current date and time.