gefvert.org

MySQL Function to Calculate Excel-style Dates

2011-10-18

drop function if exists exceldate;

delimiter //

-- Function that returns an Excel-style or Delphi-style date value
-- from a MySQL date. A date value of 0 represents 1899-12-30.</em>
create function exceldate(p_date date)
 returns int
 sql security invoker
begin
 return to_days(p_date) - 693959;
end //

delimiter ;

select...
 > Keep reading

Luhn (mod 10) Check Digit Algorithm in MySQL

2011-10-13

drop function if exists luhn;
drop function if exists luhn_check;

delimiter //

-- Function that calculates a Luhn (mod 10) check digit from a numeric string.
-- The behavior is undefined if the string contains anything else than digits.
-- Assumes that the string does...
 > Keep reading