473,413 Members | 1,778 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,413 software developers and data experts.

Help to query a date range

Please forgive me, I am a neophyte at this :)

I need to select all records created today

I can't use GetDate because it looks for a specific hour minute and second so I need a range.

ie select records created less than or equal to current date except less than 1 day ago.

I will run this query at exactly the same time everyday so that will not vary.

I can select the records of today but am not successfully excluding records of the previous day.

thank you for your advise on this.

is there a hours before function instead of days before??
Jul 22 '08 #1
2 2541
ck9663
2,878 Expert 2GB
try:

Expand|Select|Wrap|Line Numbers
  1. select * from yourtable where datediff(dd,yourdatefield,getdate()) = 0
remember that getdate() returns system date. if you ran this at 12MN, you might forgot it's already the following day.

-- CK
Jul 22 '08 #2
Dear ck9663

Thank you very much for this. It worked perfectly, exactly what I needed.

I just removed the dd, as it is not needed - I just need the difference between the datediff(dateCreated,getDate()) = 0

for day 3 I am using the same with = -2 and for day 5 the same with = -4

Just to clarify, I am sending a series of reminder emails (day 1 day 3 and day 5) so I need to identify everyday a new batch and fire off the correct template (3 different templates 1 for each day).

Thank you very much for you help on this - I am learning fast :))

Matthew


try:

Expand|Select|Wrap|Line Numbers
  1. select * from yourtable where datediff(dd,yourdatefield,getdate()) = 0
remember that getdate() returns system date. if you ran this at 12MN, you might forgot it's already the following day.

-- CK
Jul 22 '08 #3

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

Similar topics

5
by: Got2Go | last post by:
Hello Group, I have a table that has 3 columns: ID (int), datetime, Value(varchar) ID = ID for the SNMP device datetime = time record was added value = value added for that device. This...
5
by: - | last post by:
Hello to all I need help on some sql statements and wondering is anyone out there is able to help. I've extracted some data from the database into a new table consisting of 4 fields CustomerID...
1
by: Melissa Kay Beeline | last post by:
OK, here's the sitch : we have an access control system at work that registers ever entry/exit of every employee. I recently made some queries in Access so the ppl in HR could make reports (who...
3
by: Don Sealer | last post by:
I'm guessing this is pretty simple however not simple enough for me. I'm developing a database to track expenses, income, banking transactions, etc. I have a very simple query with four fields,...
6
by: paulwilliamsonremove | last post by:
Hi, I have two queries: "qryHistoryPersonIDs" that just contains the "personID" numeric field, and "qryDonations" that just contains the "personID" field, and a date field ("dDonationDate"). ...
4
by: davide507 | last post by:
Hello, I've created a select query with a date range parameter as well as a text field parameter Between and The second parameter: Like or Like Is Null. When you run the query, and...
19
by: eskelies | last post by:
I have two queries. My goal is to pull a range of numbers that fall on or in a certain date range. For example, $100 on 9/1/2007 and $200 on 9/24/2007. I want the date range to pick up both the...
1
by: RussCRM | last post by:
I need some help getting unique records from our database! I work for a small non-profit homeless shelter. We keep track of guest information as well as what services we have offered for...
4
Sandboxer
by: Sandboxer | last post by:
I want to be able to program Access to provide for me, by individual day, what my contract obligations are to my customers. Will Access recognize all the individual days in between a date range...
11
by: troy_lee | last post by:
I have two fields on a form. These two fields' values are based on an expression and represent a date range. I need to create a SQL statement that will use the returned values of these two fields...
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: 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:
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...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.