Convert Clarion Date to SQL DateTime


#1

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


Convert Clarion Standard Time to SQL Time
#2

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


#3

This could be an interesting project to watch too:


#4

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