473,657 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

date/time query help

My table has a record called date/time - filled (not surprisingly) with a
date and time. I can format the date in one query field, also the time,
using format in an expression. My user wants me to provide a listing of all
table entries between 22:00 and 07:30 the next day, between a given set of
dates (typically one week apart but in practice between any dates
specified).

My query works ok for 1 date - entering 2 dates, one for 22:00 - 23:59 and
another for 00:00 - 07:30, but for a whole date range... Any help please
guys?

Lap
--
Thanks,
Chris
cc****@NOSPAMec lipse.co.uk
Nov 12 '05 #1
17 25893
> My table has a record called date/time - filled (not surprisingly) with a
date and time. I can format the date in one query field, also the time,
using format in an expression. My user wants me to provide a listing of all
table entries between 22:00 and 07:30 the next day, between a given set of
dates (typically one week apart but in practice between any dates
specified). My query works ok for 1 date - entering 2 dates, one for 22:00 - 23:59 and
another for 00:00 - 07:30, but for a whole date range... Any help please
guys?

SELECT YourFields FROM YourTable WHERE YourDateTime
Between (DateSerial(200 3,9,10)+TimeSer ial(22,0,0))
And (DateSerial(200 3,9,11))+TimeSe rial(7,30,0));

HTH - Peter

--
No mails please.
Nov 12 '05 #2
Thanks - but how can the date ranges be changed within the query as a
parameter?
--
Thanks,
Chris
cc****@NOSPAMec lipse.co.uk

"Peter Doering" <ne**@doering.o rg> wrote in message
news:bj******** ****@ID-204768.news.uni-berlin.de...
My table has a record called date/time - filled (not surprisingly) with a date and time. I can format the date in one query field, also the time,
using format in an expression. My user wants me to provide a listing of all table entries between 22:00 and 07:30 the next day, between a given set of dates (typically one week apart but in practice between any dates
specified).

My query works ok for 1 date - entering 2 dates, one for 22:00 - 23:59 and another for 00:00 - 07:30, but for a whole date range... Any help please
guys?

SELECT YourFields FROM YourTable WHERE YourDateTime
Between (DateSerial(200 3,9,10)+TimeSer ial(22,0,0))
And (DateSerial(200 3,9,11))+TimeSe rial(7,30,0));

HTH - Peter

--
No mails please.

Nov 12 '05 #3
What should the day be? If it should refer to between 22:00 today and 07:30
tomorrow, you could try something like:

SELECT YourFields FROM YourTable WHERE YourDateTime
Between (Date()+TimeSer ial(22,0,0))
And (DateAdd("d", 1, Date())+TimeSer ial(7,30,0));

Otherwise, you're going to have to have your users input a date.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
"Lapchien" <cc****@NOSPAMe clipse.co.uk> wrote in message
news:10******** *******@ananke. eclipse.net.uk. ..
Thanks - but how can the date ranges be changed within the query as a
parameter?
--
Thanks,
Chris
cc****@NOSPAMec lipse.co.uk

"Peter Doering" <ne**@doering.o rg> wrote in message
news:bj******** ****@ID-204768.news.uni-berlin.de...
My table has a record called date/time - filled (not surprisingly) with
a
date and time. I can format the date in one query field, also the
time, using format in an expression. My user wants me to provide a listing of
all table entries between 22:00 and 07:30 the next day, between a given
set
of dates (typically one week apart but in practice between any dates
specified).

My query works ok for 1 date - entering 2 dates, one for 22:00 - 23:59 and another for 00:00 - 07:30, but for a whole date range... Any help

please guys?

SELECT YourFields FROM YourTable WHERE YourDateTime
Between (DateSerial(200 3,9,10)+TimeSer ial(22,0,0))
And (DateSerial(200 3,9,11))+TimeSe rial(7,30,0));

HTH - Peter

--
No mails please.


Nov 12 '05 #4

..... WHERE format(YourDate TimeField, "yyyymmddhh nn") Between
format(Date1 + #22:00#,"yyyymm ddhhnn") AND format(Date2 +
#07:00#,"yyyymm ddhhnn")
On Wed, 10 Sep 2003 19:38:42 +0100, "Lapchien"
<cc****@NOSPAMe clipse.co.uk> wrote:
My table has a record called date/time - filled (not surprisingly) with a
date and time. I can format the date in one query field, also the time,
using format in an expression. My user wants me to provide a listing of all
table entries between 22:00 and 07:30 the next day, between a given set of
dates (typically one week apart but in practice between any dates
specified).

My query works ok for 1 date - entering 2 dates, one for 22:00 - 23:59 and
another for 00:00 - 07:30, but for a whole date range... Any help please
guys?

Lap


Nov 12 '05 #5
On Wed, 10 Sep 2003 22:23:54 +0100, Lapchien wrote:
Thanks - but how can the date ranges be changed within the query as a
parameter?


What are you entering? 1 date or both dates, time as well or is it fix? I
assume you enter one date and calculate the next day:

- In your query go to menu query - parameters and create a parameter called
MyDate, type Date/Time.
- Use following syntax in the WHERE clause:

Between (DateSerial(Yea r([MyDate]),Month([MyDate]),
Day([MyDate]))+TimeSerial(1 0,0,0))
And (DateSerial(Yea r([MyDate]),Month([MyDate]),
Day([MyDate]))+1+TimeSerial (6,0,0))

If the example isn't quite right you have to play around with the
variables, e.g. create a 2nd parameter in case you want to enter 2 dates,
or a 3rd and 4th for the times.

Peter

--
No mails please.
Nov 12 '05 #6
> Between (DateSerial(Yea r([MyDate]),Month([MyDate]),
Day([MyDate]))+TimeSerial(1 0,0,0))
And (DateSerial(Yea r([MyDate]),Month([MyDate]),
Day([MyDate]))+1+TimeSerial (6,0,0))


That was too fast:

Between ([MyDate]+TimeSerial(10, 0,0)) And ([MyDate]+1+TimeSerial(7 ,30,0))

will do too. ;-)

Peter

--
No mails please.
Nov 12 '05 #7
hmm okay - maybe I can add a bit more info. The query needs to report a
listing of all entries to the db between 22:00 and 07:30 the next day, over
a given week, or 2 days, or a month - whatever the 'start date' and 'end
date' might be, depending on who wants the report. I assume that the user
will have to enter these 2 dates...

Thanks so far guys!
"Peter Doering" <ne**@doering.o rg> wrote in message
news:bj******** ****@ID-204768.news.uni-berlin.de...
Between (DateSerial(Yea r([MyDate]),Month([MyDate]),
Day([MyDate]))+TimeSerial(1 0,0,0))
And (DateSerial(Yea r([MyDate]),Month([MyDate]),
Day([MyDate]))+1+TimeSerial (6,0,0))


That was too fast:

Between ([MyDate]+TimeSerial(10, 0,0)) And ([MyDate]+1+TimeSerial(7 ,30,0))

will do too. ;-)

Peter

--
No mails please.

Nov 12 '05 #8
This is what I have (but returns no records...)

Between [first date] And [second date] And Between (+TimeSerial(22 ,0,0)) And
(+TimeSerial(7, 30,0))

"Peter Doering" <ne**@doering.o rg> wrote in message
news:bj******** ****@ID-204768.news.uni-berlin.de...
Between (DateSerial(Yea r([MyDate]),Month([MyDate]),
Day([MyDate]))+TimeSerial(1 0,0,0))
And (DateSerial(Yea r([MyDate]),Month([MyDate]),
Day([MyDate]))+1+TimeSerial (6,0,0))


That was too fast:

Between ([MyDate]+TimeSerial(10, 0,0)) And ([MyDate]+1+TimeSerial(7 ,30,0))

will do too. ;-)

Peter

--
No mails please.

Nov 12 '05 #9
> This is what I have (but returns no records...)
Between [first date] And [second date] And Between (+TimeSerial(22 ,0,0)) And
(+TimeSerial(7, 30,0))


But this is not what I suggested. With this clause you'll get e.g.:

Between #9/10/2003# And #9/11/2003# And Between #12/30/1899 22:00:00# And
#12/30/1899 07:30:00#

So it won't return any records.

With this clause...

Between ([first date] + TimeSerial(22,0 ,0))
And ([second date] + TimeSerial(7,30 ,0))

.... you'll get:
Between #9/10/2003 22:00:00# And #9/11/2003 07:30:00#
HTH - Peter

--
No mails please.
Nov 12 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
4270
by: Dave | last post by:
Hey folks, I'm moving from ASP to PHP and I must say that on using this for only a day it is MUCH simpler to get things going. Already have made a VERY basic blog site for myself in a very short period of time. Anyhow I have a datetime issue: On my blog site I capture the date like this: $date=date("Y-m-d g-i-s"); When I display this date later it is 2 hours being my time. I'm guessing
2
4711
by: zaceti | last post by:
I'm new to MySQL and I am having a problem selecting the highest valued date/time for a particular day. Here is the table structure: +--------------+-----------------+-----+----+--------+--------------+ | Field | Type | Null| Key| Default|Extra | +--------------+-----------------+-----+----+--------+--------------+ | id | int(10) unsigned| | PRI| NULL |auto_increment| | timestamp | datetime ...
11
5889
by: Dixie | last post by:
How can I programatically, take some Date/Time fields present in a table in the current database and change their type to text? dixie
7
4229
by: Jerome | last post by:
Hallo, I know a lot has already been told about date/time fields in a database but still confuses me, specif when dealing with SQLserver(Express). It seems that sqlserver only accepts the date in a "yyyyMMdd" format? (difference between Express and MSDE2000A ?) What is the one and only true way to deal with this problem in VB2005: Local settings are Dutch (Belgium) ; thus date is in "dd/MM/yy" (or perhaps dd/MM/yyyy) and time in...
3
17591
by: phried1 | last post by:
I have created a form and inserted the following tables: Date Entered Time Entered Date Modified Time Modified Essentially how and where can I have these dates and times recorded so when the user creates a new record that date and time stamp is populating as well as if the user modifies the data, that date and time stamp is populationg. Whereby if the record was created yesterday, and the user modified the record today, i would see...
5
1561
by: Photo | last post by:
Hello everyone this is my first post so as you could guess I need some help. Here is my situation, I have 2 tables, one caled personnel and one called DET_Dates, DET_Dates is linked to Personnel on Admin_ID. The Perrsonnel table has a list of names and dates pertaining to that person, the DET_Date table contains events and dates of events that each person in the Personnel table participated in. What I need to do and have been trying to do is...
3
2204
by: ebasshead | last post by:
Hi everybody, I have an access database that books houses for people to stay in. I'm trying to build a query which will find clashes in booking dates, ie it will compare arrival and departure dates of houses and if there is an overlap of dates, those houses with booking clashes will be listed. I'm trying to write an iif statement to compare dates but I can't get my head around how to go about it. Any help would be massively appreciated cos I...
20
1979
by: kujito | last post by:
I'm working with mine production data in Access 2007. I'll try to make this make sense and keep it simple (mostly to not confuse myself further). The range of years operating varies between mines. For example, I have data for one of the mines for the years 1961 through 1991. How can I get a query to report the years of operation, like 1961 - 1991, in a single cell? The Production.Year column of the Production table is formatted as a...
4
2002
by: flyboy3300 | last post by:
I am trying to set up a form in db with items that have to be completed and when completed they check a "check box" and then I would like that to show a date/time in a text box. I have tried to use macros to do this with no luck...please help
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8827
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7333
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4315
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2731
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1620
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.