Wednesday, 14 August 2013

SQL Server - INSERT Month and Day only in the database

SQL Server - INSERT Month and Day only in the database

I am currently making a computerized payroll system and I'm having a
problem with what query I should use to check if the Employee is present
during a Holiday.
What I did was I created this query:
CREATE TABLE Holidays(
id INT PRIMARY KEY IDENTITY,
holidayName VARCHAR(55),
holidayDate DATE <---- This is my problem
);
CREATE TABLE EmployeeHolidays(
id INT PRIMARY KEY IDENTITY,
employeeId INT FOREIGN KEY REFERENCES Employees(id),
holidayId INT FOREIGN KEY REFERENCES Holidays(id),
workingDate DATE,
employeeTimeIn TIME,
employeeTimeOut TIME
);
Now the problem lies within inserting the DATE in Holidays.holidayDate
because I must insert the Year even though I only need the month to do a
conditional statement for the EmployeeHolidays using C#.
What approach should I use for this problem? Should I just make a dummy
year as an input for the Holidays.holidayDate? Should I make the
Holidays.holidayDate a VARCHAR and just parse it as a DATE data type along
with the current year? What queries should I use for this approach?

No comments:

Post a Comment