Try OpenEdge Now
skip to main content
.NET Open Clients
Passing Parameters : ABL temp-table to ADO.NET DataTable mappings : Resolving differences between ABL and .NET date and time implementations
 

Resolving 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:
1. The System.DataTime.Today property returns a DateTime instance initialized with the current date.
2. The System.DataTime.Now property returns a DateTime instance initialized with the current date and time.