Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8459421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:19:34+00:00 2026-06-10T13:19:34+00:00

CREATE TABLE Reservation( ReservationID int IDENTITY (1,1) NOT NULL, CustomerID int NOT NULL, RoomNo

  • 0
    CREATE TABLE "Reservation"(

    ReservationID int IDENTITY (1,1) NOT NULL,
    CustomerID int NOT NULL,
    RoomNo int NOT NULL,
    CheckInDate date NULL,
    CheckOutDate date NULL,
    NoOfDays int NULL,

    CONSTRAINT PK_Reservation PRIMARY KEY(ReservationID),

    CONSTRAINT FK_Reservation_Customers_CustID FOREIGN KEY(CustomerID)  
        REFERENCES dbo.Customers(CustomerID),

    CONSTRAINT FK_Reservation_Rooms_RoomNo FOREIGN KEY(RoomNo)
        REFERENCES dbo.Rooms(RoomNo)
)


INSERT Reservation(CustomerID,RoomNo,CheckInDate,CheckOutDate,NoOfDays)
        VALUES(1,101,'2012-01-01','2012-01-30',DATEDIFF(NoOfDays,'CheckInDate','CheckOutDate'))

Can someone please tell me how i can calculate the number of days between “CheckInDate” and “CheckOutDate” then have this value in the insert statement for NoOfDays. It’s hard to explain i hope you understood what i’m trying to achieve here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:19:35+00:00Added an answer on June 10, 2026 at 1:19 pm

    UPDATED:

    Try this:

    INSERT Reservation(CustomerID,RoomNo,CheckInDate,CheckOutDate,NoOfDays)
        VALUES(1,101,'2012-01-01','2012-01-30',DATEDIFF(day,'2012-01-01','2012-01-30'));
    

    SQL Fiddle

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

create table ImagenesUsuario { idImagen int primary key not null IDENTITY } This doesn't
CREATE TABLE Customer ( customerID int identity (500,20) CONSTRAINT . . dateCreated datetime DEFAULT
create table [User] ( UserId int primary key identity(1,1), FirstName nvarchar(256) not null, LastName
Create table FavoriteDish ( FavID int identity (1,1) primary key not null, DishID int
CREATE TABLE [dbo].[ProjectTasks] ( [TaskID] [int] IDENTITY(1,1) NOT NULL, ... [DefaultTaskValue] [int] NULL )
CREATE TABLE [schema].[table] ( [column1] int IDENTITY NOT NULL, [column2] int NULL, [column3] int
CREATE TABLE `tbl_atn` ( `atn_id` int(15) NOT NULL AUTO_INCREMENT, `eng_id` int(15) DEFAULT NULL, `visit`
create table snippet( id int not null auto_increment, primary key(id), idlanguage int not null,
CREATE TABLE SupplierQuote ( supplierQuoteID int identity (3504,2) CONSTRAINT supquoteid_pk PRIMARY KEY, PONumber int
CREATE TABLE `ost_staff` ( `staff_id` int(11) unsigned NOT NULL auto_increment, `group_id` int(10) unsigned NOT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.