Tuesday, March 23, 2010

Date Variable

Many times it require to check whether the date in the particular variable is assigned which can be checked by using

If IsDate(variable of type date) Then .......

Also, in case to verify that valid value is stored in the database while retrieving, to avoid null exception, it can be checked by using datareader as

If dr.isdbnull(column index) Then...
Or
If dr(mydate column Name/Index) Is DBNull.Value Then

Usefull tips:
in VB.net empty date is 1/1/1900
to verify correct date, ensure mydate.year > 1900

No comments: