473,503 Members | 1,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sql Statement problem with a Date() - number of days

I have a SQL Statement that I'm having a problem with:

Dim sSQL As String, sLen As Integer, stCaption As String, sAgeB As
Integer

sAgeB = 777

sSQL = "SELECT [Qry_All_Reg].* FROM [Qry_All_Reg] WHERE "

'sSQL = sSQL & " [Qry_All_Reg].[DOB] < now() - sAgeB AND"
sSQL = sSQL & " [Qry_All_Reg].[DOB] < now() - 777 AND"
The line with the "now() - 777" will work, but the line before it will
not. I made sAgeB equal to 777 and made sAgeB an Integer but it
doesn't work.

What am I missing?

TIA
Nov 12 '05 #1
2 2496
Should be

sSQL = sSQL & " [Qry_All_Reg].[DOB] < now() - " & sAgeB & " AND"

Jeff

<ynott> wrote in message news:1b********************************@4ax.com...
I have a SQL Statement that I'm having a problem with:

Dim sSQL As String, sLen As Integer, stCaption As String, sAgeB As
Integer

sAgeB = 777

sSQL = "SELECT [Qry_All_Reg].* FROM [Qry_All_Reg] WHERE "

'sSQL = sSQL & " [Qry_All_Reg].[DOB] < now() - sAgeB AND"
sSQL = sSQL & " [Qry_All_Reg].[DOB] < now() - 777 AND"
The line with the "now() - 777" will work, but the line before it will
not. I made sAgeB equal to 777 and made sAgeB an Integer but it
doesn't work.

What am I missing?

TIA

Nov 12 '05 #2
ynott <> wrote in message news:<1b********************************@4ax.com>. ..
I have a SQL Statement that I'm having a problem with:

Dim sSQL As String, sLen As Integer, stCaption As String, sAgeB As
Integer

sAgeB = 777

sSQL = "SELECT [Qry_All_Reg].* FROM [Qry_All_Reg] WHERE "

'sSQL = sSQL & " [Qry_All_Reg].[DOB] < now() - sAgeB AND"
sSQL = sSQL & " [Qry_All_Reg].[DOB] < now() - 777 AND"
The line with the "now() - 777" will work, but the line before it will
not. I made sAgeB equal to 777 and made sAgeB an Integer but it
doesn't work.

What am I missing?

TIA


take sAgeB out of the speech marks i.e.
sSQL = sSQL & " [Qry_All_Reg].[DOB] < now() - " & sAgeB & " AND"
Nov 12 '05 #3

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

Similar topics

7
11415
by: mark | last post by:
Access 2000: I creating a report that has a record source built by the user who selects the WHERE values. An example is: SELECT * FROM CHARGELOG WHERE STDATE Between #10/27/2003# And...
8
2830
by: Gompie | last post by:
Why does the function DMin("Abs(!- #" & & "#)";"SomeTable") not work properly with datefields. It always finds the closest difference with a later date only, if an earlier date in the table is...
5
60034
by: Kiran | last post by:
Hi, Please help on date functions in C#. I would like to know the relevant exampl to retrieve 2 weeks before date from the current date, 1 month before date from the current date and number...
29
9028
by: james | last post by:
I have a problem that at first glance seems not that hard to figure out. But, so far, the answer has escaped me. I have an old database file that has the date(s) stored in it as number of days. An...
20
2937
by: none | last post by:
I have managed to get the below script *almost* working. However, it still has a problem calculating the number of months. The date I am trying to calculate from is Oct 15, 1994. With the correct...
1
1277
by: Budd | last post by:
Hi everyone i got a problem on date, it is... 1, i get the date from calendar component 2, compare today and selected date is equal (compare method) 3 count the number of day between this...
4
15666
by: jamesyreid | last post by:
Hi, I'm really sorry to post this as I know it must have been asked countless times before, but I can't find an answer anywhere. Does anyone have a snippet of JavaScript code I could borrow...
2
6587
by: jonathan184 | last post by:
Hi I am trying to create a shell script that will look for a contracthead file first and if the contract head file does not exist on day1 exit script. Now on day2 if contracthead exists or...
1
1485
by: Darknight850 | last post by:
Hello Every One, I am having a problem with an IIF statement in a query I have going. Before I start I would like to say I have had some problems in the past with supplying enough information, if...
7
4142
by: kr151080 | last post by:
Ok so I am messing around with a program and have no idea how to go about doing this but here is the code for the class date.... public class Date { private int dMonth; private int dDay;...
0
7199
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,...
0
7273
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
7322
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...
1
6982
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
7451
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
5572
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,...
0
4667
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...
0
3161
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...
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.