Q:

Invalid Datatype trying to alter table

I got a table which I used the below code to create.
create table Meter (MeterID CHAR(8) CONSTRAINT MeterPK PRIMARY KEY,
                Value CHAR(8) CONSTRAINT ValueNN NOT NULL,
                InstalledDate Date CONSTRAINT InDateNN NOT NULL);

Then I tried adding a derived column that adds 6 months to the installeddate.
alter table meter add ExpiryDate as (add_months(installedDate,6)) not null;

This returns an error of invalid datatype.
I read somewhere that I do not have to specify the datatype of ExpiryDate as it can be derived from the function. So where did I go wrong?
EDIT: Turns out Mike was right. I used the trigger method to get things going, but I was confused whether I'm using mysql or oracle. Think in the end I'm using oracle actually. Have problems with the trigger but turns out I do not need to have the command "set" in the trigger. Below is the code that works.
CREATE OR REPLACE
TRIGGER trigexpdate1
BEFORE INSERT ON Meter
FOR EACH ROW
BEGIN
  :NEW.ExpiryDate := ADD_MONTHS(:NEW.InstalledDate, 6);
END;

If I don't have the begin and end in the statement, it will throw an error saying illegal trigger specification.

A:

MySQL doesn't support 

derived columns in table definitions,
a function named add_months(), or
inline constraints.

This is a more or less standard way to write that statement in MySQL.
create table `Meter` (
  `MeterID` CHAR(8) NOT NULL,
  `Value` CHAR(8) NOT NULL,
  `InstalledDate` Date NOT NULL,
  primary key (`MeterID`)
);

You have two options for a derived column like "ExpiryDate". 

Create a view, and do the date arithmetic in the view. Use date_add().
Add the column "ExpiryDate" to the table, and keep it up-to-date with a trigger.

BEFORE INSERT trigger example
create table `Meter` (
  `MeterID` CHAR(8) NOT NULL,
  `Value` CHAR(8) NOT NULL,
  `InstalledDate` Date NOT NULL,
  `ExpiryDate` Date not null,
  primary key (`MeterID`)
);

create trigger trigexpdate1 
before insert on `Meter` 
FOR EACH ROW 
  SET NEW.`ExpiryDate` = date_add(NEW.`InstalledDate`, interval 6 month);

Note how ExpiryDate changes from the insert statement to the select statement below.
insert into Meter 
values ('1', '1', '2014-07-01', '2014-07-01');

select * from Meter;

MeterID  Value  InstalledDate  ExpiryDate
--
1        1      2014-07-01     2015-01-01

