How to Convert a Null Dateby Jim Campbell
The "null" value is a database value used to set "nothing" to the table field. If you do not know what value to set the field, the "null" value leaves it blank. Convert your null database values to a date using the Structured Query Language (SQL). The SQL language runs on your database server and changes the null table fields to an actual date. Use the "update" command to edit these dates.
View the data in your table. This helps you decide if all your date variables are null or if some are populated with dates. You don't want to overwrite any date values, so it's important to check current values. The following code shows an example of how to search date values:
select myDateField from customer
Replace "myDateField" with the date field in your table.
Convert your null values to dates. In this example, null dates in the customer table are converted. However, you can convert any null dates in any table. The following code changes all null values to "1/1/2010":
update customer set myDateField where myDateField is null
Verify the update was successful. Since all null dates are converted, you should retrieve no records when attempting to select all values with a null reference. The following code verifies your conversion worked:
select * from customer where myDateField is null
- photo_camera calendar and pen image by Dariusz Urbanczyk from Fotolia.com
Click here to provide feedback on this article