473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Time and date trouble

36
HI All,
Im new to access(and im no vb pro too), SOooo Im stuck in a project!! here it goes

I have a two tables
1 Rooms
---------------------(holds room details)
Room no
Room type

2 Reservation
--------------------(Holds reservation)
Room No
Start Date
Start Time
End Date
End Time

from this i like get the reservation detail mostly notreserved details
like: if a room reserved
2007/06/05 12:00 to 2007/06/07 13:00
this room shuold not apear in the serch query results (if i serched for free roms
between 2007/06/05/ any time to 2007/06/06 any time

please bsomebody help
Jul 6 '07 #1
11 1494
gayano
36
I tried this

SELECT Room No
FROM Rooms
WHERE RoomNo Not In (
Select RoomNo from Reservation
Where [SDate] + [Stime] Between [ssdate] + [sstime] And [dddate] + [ddtime]);

But the thing is it works with the date but it wont calculate time

whats the problem??
Jul 6 '07 #2
kepston
97 Expert
I tried this

SELECT Room No
FROM Rooms
WHERE RoomNo Not In (
Select RoomNo from Reservation
Where [SDate] + [Stime] Between [ssdate] + [sstime] And [dddate] + [ddtime]);

But the thing is it works with the date but it wont calculate time

whats the problem??
If you leave the time blank, it will not calculate correctly. Enter [sstime] as 0:00 and [ddtime] as 23:59.
or change your SQL to
Expand|Select|Wrap|Line Numbers
  1. Where [SDate] + [Stime] Between [ssdate] +Nz([sstime]) And [dddate] + Nz([ddtime])
Nz() converts Null to zero
Jul 6 '07 #3
gayano
36
If you leave the time blank, it will not calculate correctly. Enter [sstime] as 0:00 and [ddtime] as 23:59.
or change your SQL to
Expand|Select|Wrap|Line Numbers
  1. Where [SDate] + [Stime] Between [ssdate] +Nz([sstime]) And [dddate] + Nz([ddtime])
Nz() converts Null to zero

kepston,

Thank you for your quick reply,

Tried Your Code The result is the same, Even if I Input the Time using the parameter input.

Here is my Resrvation Table Look like:

Room No Start Date Start Time End Date Ennd Time
.................................................. .................................................. ..............

123 2007/07/06 10:00 2007/07/06 12:00
1234 2007/07/06 13:00 2007/07/06 20:00



If I use the code i earlier mentioned. ( the parameter inputs are Start Date = 2007/07/06, End Date = 2007/07/06, Start Time 09:00, End Time 11:30)
then result should be ..

Room No
-----------------
1234

Isn't It?? But the result shows both Room No 123 and 1234

Any Help ..................
Jul 6 '07 #4
MMcCarthy
14,534 Expert Mod 8TB
Try this ...

Expand|Select|Wrap|Line Numbers
  1. SELECT Room No
  2. FROM Rooms
  3. WHERE RoomNo Not In 
  4. (Select RoomNo from Reservation
  5. WHERE ([Start Date] Between [ssdate] And [dddate])
  6. AND ([Start Time] Between [sstime] And [ddtime]))
  7.  
Jul 7 '07 #5
gayano
36
It went OK When I used it on a form,
Thank you Thank you Thank you for the replys's
Jul 7 '07 #6
MMcCarthy
14,534 Expert Mod 8TB
It went OK When I used it on a form,
Thank you Thank you Thank you for the replys's
No problem, you're welcome.
Jul 7 '07 #7
kepston
97 Expert
I wonder why my solution didn't work for gayano.
I tried it successfully before I posted.
Jul 8 '07 #8
MMcCarthy
14,534 Expert Mod 8TB
I wonder why my solution didn't work for gayano.
I tried it successfully before I posted.
I don't think concatenating the two fields would necessarily give a timestamp unless they are formatted.
Jul 8 '07 #9
kepston
97 Expert
I don't think concatenating the two fields would necessarily give a timestamp unless they are formatted.
If the data type is DateTime, then surely the + operator will add the underlying serial number for the date to the fractional number for the time, producing a new DateTime serial number. Or is it that Access takes the parameter as a string and has to infer the data type?
Jul 9 '07 #10
MMcCarthy
14,534 Expert Mod 8TB
If the data type is DateTime, then surely the + operator will add the underlying serial number for the date to the fractional number for the time, producing a new DateTime serial number. Or is it that Access takes the parameter as a string and has to infer the data type?
It should work but there are issues with the formatting of dates in Access and this kind of concatenation would revert the dates to the default format. Thats why I said you would need to impose a format when concatenating the date and time.
Jul 10 '07 #11
kepston
97 Expert
Further examples of how and when:
Literal DateTimes and Their Delimiters (#). Article by NeoPa
VBA Filter by date

Thanks to the wise, and knowledgeable Mary and NeoPa.
Jul 10 '07 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: xool | last post by:
Hi all i'm trying to compare a variable containing a date with todays date. if tempdate <= now()then trouble is... tempdate = 05/12/2003 now() = 11/09/2003 14:04:06
17
by: Mike A | last post by:
Hi, I'm hoping someone can help me with this. I have a URL for which I'd like to limit access to by time. For example,say I have a URL that I don't want accessable on Monday mornings between...
2
by: Robert | last post by:
I have no problem storing dates + times in a System.DateTime object. In addition, it's easy to output a Time as a string from an existing Date/Time. But I'm having trouble storing a time only. ...
18
by: Robin Lawrie | last post by:
Hi again, another problem! I've moved from an Access database to SQL server and am now having trouble inserting dates and times into seperate fields. I'm using ASP and the code below to get the...
5
by: Paul | last post by:
Hi All, I know this is probably simple, but I'll ask anyway. I have a form which when submitted to the database the field in the database automatically adds date and time which is fine. My only...
2
by: Steve Miller | last post by:
hello... i am a 'user' of access, meaning, i import excel files, join, and merge....that's about the extent of my expertise with ms-access. my boss wants me to create an access application that...
6
by: D | last post by:
Hello all...I have an issue with one of my java script functions that I'm hoping someone can easily help with. I have a web based application that we use to create/sign up for overtime. When we...
3
by: colleen1980 | last post by:
Hi: Data in my table is in that format. How to i separate date with time. 11/9/2006 10:10:46 AM Thank You.
5
by: Omer | last post by:
hi Everyone, I am using ASP.Net 2.0. When user logins, I check the credential and then made the cookie. My hoster's server is in Arizona region and I am in Pakistan. I set cookie's expiration time...
3
by: Gretsch | last post by:
Web, html, javascript, Hi, I need to calculate the time since this .htm file was last modified. {which I can then use in a calculation, rather than display, so days&decimals format would be OK}...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.