Dương Dũng
Dương Dũng

Reputation: 5

How to check a time variable is greater than 1 hour?

I have an issue that has to check a time variable is greater than 1 hour. Help me! This is my code:

CREATE TABLE MOVIE
(
    MovieID int identity(1,1) NOT NULL PRIMARY KEY,
    MovieName varchar(50) NOT NULL,
    Duration time check(HOURS(Duration) >= 1) NOT NULL,
    Genre int check(Genre between 1 and 8) NOT NULL,
    Direction varchar(50) NOT NULL,
    [Money] money NOT NULL,
    Comments varchar(100),
)

Upvotes: 0

Views: 1274

Answers (1)

Jawi
Jawi

Reputation: 360

You can check a time variable like this way

check(DATEPART(HOUR, Duration) >= 1)

Upvotes: 1

Related Questions