Convert Clarion Date to SQL DateTime

If you have stored your dates in clarion format this snippet can be used to convert them to SQL DateTime values.

1 Like

I think there may be an issue with how this handles nulls and out of range dates though.

This could be an interesting project to watch too:

For MySql this works:

DROP FUNCTION IF EXISTS get_sql_date;
CREATE FUNCTION get_sql_date(clarionDate INT)
  RETURNS DATE 
  
  DETERMINISTIC
BEGIN

  DECLARE sqlDate DATE;
  SET sqlDate = DATE_ADD('1801-01-01', INTERVAL clarionDate  - 4 DAY); 
  
  RETURN sqlDate;
  
END
1 Like