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

Home Posts Topics Members FAQ

counting days in query

Ike
How can I make a query such that in the "WHERE" part of my clause, I want to
put something to the effect that, say, X days have elapsed since a given
date.
For example, suppose in my table, I have a boolean field and a date field.
I want to create a query asking for those rows where X days have elapsed
from the date field in a row and the boolean, say, is false.

Do I need to create a third field, called, say "X" for how many days have
elapsed between the date field and today, and update every row in the table
every day?

Thanks, Ike
Jul 19 '05 #1
6 7165
Ike wrote:
How can I make a query such that in the "WHERE" part of my clause, I want to
put something to the effect that, say, X days have elapsed since a given
date.
For example, suppose in my table, I have a boolean field and a date field.
I want to create a query asking for those rows where X days have elapsed
from the date field in a row and the boolean, say, is false.


http://www.mysql.com/doc/en/Date_and...functions.html

From the link above:

Here is an example that uses date functions. The following query selects
all records with a date_col value from within the last 30 days:

mysql> SELECT something FROM tbl_name
WHERE TO_DAYS(NOW()) - TO_DAYS(date_co l) <= 30;

Jul 19 '05 #2
Ike wrote:
How can I make a query such that in the "WHERE" part of my clause, I want to
put something to the effect that, say, X days have elapsed since a given
date.
For example, suppose in my table, I have a boolean field and a date field.
I want to create a query asking for those rows where X days have elapsed
from the date field in a row and the boolean, say, is false.


http://www.mysql.com/doc/en/Date_and...functions.html

From the link above:

Here is an example that uses date functions. The following query selects
all records with a date_col value from within the last 30 days:

mysql> SELECT something FROM tbl_name
WHERE TO_DAYS(NOW()) - TO_DAYS(date_co l) <= 30;

Jul 19 '05 #3
Ike
Thank you. My problem is a little trickier however because my date's are not
date objects, but rather char[] representations of date objects (Strings),
i.e. '2003-12-28'

Is there a way I can convert the Strings to date objects within my query?

Thanks, Ike
"Aggro" <sp**********@y ahoo.com> wrote in message
news:_a******** ******@read3.in et.fi...
Ike wrote:
How can I make a query such that in the "WHERE" part of my clause, I want to put something to the effect that, say, X days have elapsed since a given
date.
For example, suppose in my table, I have a boolean field and a date field. I want to create a query asking for those rows where X days have elapsed
from the date field in a row and the boolean, say, is false.


http://www.mysql.com/doc/en/Date_and...functions.html

From the link above:

Here is an example that uses date functions. The following query selects
all records with a date_col value from within the last 30 days:

mysql> SELECT something FROM tbl_name
WHERE TO_DAYS(NOW()) - TO_DAYS(date_co l) <= 30;

Jul 19 '05 #4
Ike
Thank you. My problem is a little trickier however because my date's are not
date objects, but rather char[] representations of date objects (Strings),
i.e. '2003-12-28'

Is there a way I can convert the Strings to date objects within my query?

Thanks, Ike
"Aggro" <sp**********@y ahoo.com> wrote in message
news:_a******** ******@read3.in et.fi...
Ike wrote:
How can I make a query such that in the "WHERE" part of my clause, I want to put something to the effect that, say, X days have elapsed since a given
date.
For example, suppose in my table, I have a boolean field and a date field. I want to create a query asking for those rows where X days have elapsed
from the date field in a row and the boolean, say, is false.


http://www.mysql.com/doc/en/Date_and...functions.html

From the link above:

Here is an example that uses date functions. The following query selects
all records with a date_col value from within the last 30 days:

mysql> SELECT something FROM tbl_name
WHERE TO_DAYS(NOW()) - TO_DAYS(date_co l) <= 30;

Jul 19 '05 #5
Ike
Ah, I see now how to do it with strings!

...WHERE TO_DAYS(NOW()) - TO_DAYS(CAST(la ndondate AS DATE)) <= 10;

assuming landondate column of Strings!

Thank you, Ike
Jul 19 '05 #6
Ike
Ah, I see now how to do it with strings!

...WHERE TO_DAYS(NOW()) - TO_DAYS(CAST(la ndondate AS DATE)) <= 10;

assuming landondate column of Strings!

Thank you, Ike
Jul 19 '05 #7

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

Similar topics

6
1825
by: edwardfredriks | last post by:
I'm looking for a script that, instead of counting down, can "count up" from a given date. So the output should be something like "(xx) days since (date/event)" or "(date/event) was (xx) days ago". Does anybody know where to find a script like that, or could someone code one for me? Thanks in advance. Yours,
4
4679
by: Chad Reid | last post by:
Hello, I have a bit of code that obviously doesn't work, but I need help creating a query that would have the same effect as if this query was working. SELECT * FROM (SELECT Count(*) AS numMarried FROM tblClients WHERE mID = 1), (SELECT Count(*) AS numSingle FROM tblClients WHERE mID = 2), (SELECT Count(*) AS numDivorced FROM tblClients WHERE mID = 3),
3
1962
by: Megan | last post by:
hi everybody- i'm having a counting problem i hope you guys and gals could give me some help with. i have a query that retrieves a bevy of information from several different tables. first let me give you a little background. this database is kind of like a human resources database. it collects info about people, where they work, and if they have any work-related issues where they work.
5
3504
by: ChadDiesel | last post by:
Hello Again, I want to assign a number to each record that will be part of a shipping number. I want the number value to count up until the contract number changes. Then, I want the number to go back to 1 and start counting up again until the next contract change. For example Contract 1111111 Box 1 of 2 Number Value: 1
18
2936
by: ChadDiesel | last post by:
I appreciate the help on this group. I know I've posted a lot here the last couple of weeks, but I was thrown into a database project at my work with very little Access experience. No other employee knows anything about Access. I've searched Google Groups, and that has been a lot of help, but there are some questions that I just can't find the answer to. I'll try to take it easy on the group after this question. I have one more...
21
2549
by: jennwilson | last post by:
Ok - So, I am back. I would like to count the number of times a specific record appears in a field from one table in my query and then use that value in the same query to calculate an average. I am using Access 2000 and am still learning. Background info: Overall, I am creating a database to track and calculate data regarding employee productivity. For each scheduled day, employees have a set number of points to earn. Employees...
10
2995
by: KCangelstar | last post by:
In my database, I am trying to count records from a field that meet the criteria of "SELECT DISTINCTROW WARes016.Stratum, Count((.)) AS CountOfDays FROM WARes016 INNER JOIN ON WARes016.LRS = .LRS GROUP BY WARes016.Stratum, <42 ORDER BY WARes016.Stratum; This code when run breaks the count into two groups:a count of per Stratum that meet my criteria and a count of records that don't. How do I alter the code to only show the count of...
2
1156
by: ssasser | last post by:
Hey gang, any help will be apprecited. I am trying to do a simple count of all posts to a message board from a few particular users within the past 10 days. I know the usernames and number of days that i want to query (10) and I want the output to display as follows.... Manager PostCount user1 1 user2 14 user3 20 ___________________ The query i have is but below but there is two problems...
3
1883
by: JacobZ | last post by:
Hey all, I've been struggling with this problem for a few days now. The table looks like this T_PROJECT_FILES fields: projectId, unitId Now, I want to count the number of records with different values in unitId, but with a specific value (e.g. 1) in projectId. The value of 'projectId' is coming from another form using e.g. Forms!F_Start.lblActiveProjectId.caption
0
8668
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8598
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
9152
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
9014
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
8885
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,...
1
6515
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5857
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4358
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...
3
1995
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.