Click or drag to resize

ExtensionConvertDateFromSQL Method

Convert SQL date include value null

Namespace:  Velo.Data.Helper
Assembly:  Velo.Data (in Velo.Data.dll) Version: 22.2.10.1 (22.2.10.450)
Syntax
public static Nullable<DateTime> ConvertDateFromSQL(
	this Object pDate
)

Parameters

pDate
Type: SystemObject

Return Value

Type: NullableDateTime
A date or null

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Object. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Remarks
Declaration statement
Using Velo.Data.Helper
Examples
This example get a date from a data reader.

Important: use method GetValue from data reader not method GetDateTime because method GetDateTime handling a SQL null not a system null.

this.DatePurchase = pDataRecord.GetValue(pDataRecord.GetOrdinal("DatePurchase")).ConvertDateFromSQL();
See Also