English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am doing hotel reservation system. Can anybody help me in write query for count the number of night for guests stay?
Example arrival date is 28-09-2006 and departure date is 30-09-2006. That means this guest is staying for 2 nights. So is 28-09-2006 night and 29-09-2006 night. How i want to write the query for count between the arrival date and departure date? Anybody have any idea?
Pls help :) TQ.

2006-08-16 15:48:10 · 6 answers · asked by 183 1 in Computers & Internet Programming & Design

in php language

2006-08-16 15:57:25 · update #1

yup is two night. 28-09-2006 till 30-09-006. That means that guest is staying 28-09-2006 abd 29-09-2006 nights. So is 2 nights. Hw to write query to count between that 2 days?

2006-08-16 16:00:14 · update #2

28-09-2006 that guest is staying and 29-09-2006 also the guest stay. 30-09-2006 guest is check out already. So it 2 nights. How to write query to count between arrival date(28-09-2006) and departure date(30-09-2006)

2006-08-16 16:06:36 · update #3

6 answers

what language?

mktime() makes the date.. then subtract the 2 unix timestamps and then you can divide it out to get to the precision you want.

If you have another way of making the time stamp that would also work, but the mktime() will work if nothing else

2006-08-16 15:54:37 · answer #1 · answered by Brady 3 · 0 0

I'm not sure I understand your question. Yes

9/28/06-9/30/06 Is a 2 night hotel stay.
9/28/06-9/29/06 Is One night

Write a query?

2006-08-16 22:57:01 · answer #2 · answered by whuvahgut? 2 · 0 0

The easiest way is to convert the date into number of days elapsed since January 1, 1904 and subtract he arrival date from the departure date. There are several standard algorithms to do this. That will give you the correct number of days.

Use your favourite search engine to find date calculation algorithms for the programming language you are using, and it should take you only a few minutes to put this together.

Here is a page that gives a simple algorithm and source code examples: http://alcor.concordia.ca/~gpkatch/gdate-algorithm.html

2006-08-16 23:15:09 · answer #3 · answered by Chris 2 · 0 0

In php language I can't tell you. In an MS Access Database, (similar to SQL language) in query design you create a field with the following control:
=[Departure Date field]-[Arrival Date field]

2006-08-17 04:08:13 · answer #4 · answered by Makiavel 3 · 0 0

You didn't say but if you are doing SQL queries you can write a query that will automatically calculate the number of days between two dates. In SQL help look under "date calculations"

2006-08-17 00:15:21 · answer #5 · answered by Anonymous · 0 0

I'm pretty sure you can find that formula in Excel. Just write it in the help clip. If I have some time I will try to find it and put it in here.

Hope that helps.

2006-08-16 22:54:24 · answer #6 · answered by phy333 6 · 0 0

fedest.com, questions and answers