How to create function by passing year and department

Please help me to wite the code

CREATE TABLE EMPLOYEE
(
eid INT,
ename varchar(100),
dept VARCHAR(100),
j_date varchar(50)
)

insert into employee values
(1,'AAA','prod','12-Feb-02'),
(2,'BBB','sale','30-sep-04'),
(3,'CCC','sale','16-jan-02'),
(4,'DDD','pur','1-dec-06'),
(5,'EEE','prod','28-Feb-02'),
(6,'FFF','prod','23-sep-08')

Create a function to find the early joined employee(id and name) by passing the year and dept as parameters.
note the dept might be given as empty if needed. in that case,find the early joined employee based on the year.if the dept is given,
then find the employee based on the respective dept with the year that are passing.

ex: func_early_emp('2002',") then output should be "emp id and name is 3 and CCC"
func_early_emp('2002','prod') then output should be "emp id and name is 1 and AAA"

What have you tried so far? You should start by using a proper date type instead of varchar for dates.

Im asking code for output.. please help me

Please help me to solve.

Can you please help me with code