How can SQL be used to validate a date?

I want to use SQL to validate that a date is in the format YYYYMMDD, and if the date is invalid I want to insert current date in the date field. Can I get some directions?

update a
   set yourdatefield=convert(varchar(8),current_timestamp,112)
  from yourtable as a
 where try_convert(date,yourdatefield,112) is null
;

Remember to do some tests, before executing on production data!

The date file is not null but just has bad dates and good date.

For example: good date is 20180115 (YYYYMMDD) and bad date is 20180200 (YYYYMMDD). I only want to update the bad date with the current date.

Thanks in advance.

try_convert will return either the date or NULL if the value is invalid, so bitsmed's query will only update those rows with invalid dates

INSERT INTO ( ..., date_column, ... )
SELECT ..., CASE WHEN ISDATE(incoming_date_column) = 1 THEN incoming_date_column ELSE GETDATE() END AS date_column, ...
FROM ...

UPDATE A
SET SYS_POSTING_DT=CONVERT(VARCHAR(8),CURRENT_TIMESTAMP,112)
FROM HRCSFT2.VCLIENT_ID_ALIAS AS A
WHERE TRY_CONVERT(DATE,SYS_POSTING_DT,112) IS NULL
;
Bitsmed, I'm running this ib QMF. I'm having problems getting the syntax correct.

help...

This forum is dedicated to Microsoft SQL Server so my answer was focused on that engine.

I'm not familiar with QFM, but google reveals it might be IBM's DB2 on AS400/iSeries - is that correct?
If so, this article looks interesting - especially the comment from Kent Olsen (second last message), but that requires you to have "create function" rights.

Also, the "update" statement and working with dates is slightly different on DB2 than MSSQL. You might be better off, asking your question on a DB2 forum.