473,396 Members | 2,140 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,396 software developers and data experts.

SQL Statement Problem

Sorry for the wide posting, but i really need some help and I posted
somethind a few hours ago and have heard nothing, so i thought that I would
try reacing more developers...

I am trying to get a date range from the first of whatever month is previous
to the current one to exactly one year previous to that date ie 02/01/04 to
02/01/03 to pull the appropriate section of data out...

I have tried to use:

BETWEEN MONTH(GETDATE()) - 1 + '/' + 01 + '/' + YEAR(GETDATE()) -1 AND
MONTH(GETDATE()) - 1 + '/' + 01 + '/' + YEAR(GETDATE())

But I get a Can't Convert to type INT even if i run this in a query as it's
own result...

I can't seem to find in the documentation what I am doing wrong... I am sure
that it is something simple.

Any help is appreciated.

Nov 20 '05 #1
2 834
DATEADD(DAY, - DAY(GETDATE()) + 1, DATEADD(MONTH, -1, DATEADD(YEAR, -1,
GETDATE()))) AND

DATEADD(DAY, - DAY(GETDATE()) + 1, DATEADD(MONTH, -1, GETDATE()))

"Atley" <at*****@hotmail.com> wrote in message
news:eS**************@tk2msftngp13.phx.gbl...
Sorry for the wide posting, but i really need some help and I posted
somethind a few hours ago and have heard nothing, so i thought that I would try reacing more developers...

I am trying to get a date range from the first of whatever month is previous to the current one to exactly one year previous to that date ie 02/01/04 to 02/01/03 to pull the appropriate section of data out...

I have tried to use:

BETWEEN MONTH(GETDATE()) - 1 + '/' + 01 + '/' + YEAR(GETDATE()) -1 AND
MONTH(GETDATE()) - 1 + '/' + 01 + '/' + YEAR(GETDATE())

But I get a Can't Convert to type INT even if i run this in a query as it's own result...

I can't seem to find in the documentation what I am doing wrong... I am sure that it is something simple.

Any help is appreciated.

Nov 20 '05 #2
* "Atley" <at*****@hotmail.com> scripsit:
Sorry for the wide posting, but i really need some help and I posted
somethind a few hours ago and have heard nothing, so i thought that I would
try reacing more developers...


"Some hours ago"? Give people some more time (at least 3 days).

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>
Nov 20 '05 #3

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

Similar topics

6
by: DLP22192 | last post by:
I have the following single-line if statement that is evaluating true even though it shouldn't. I have never seen this before and I am concerned that this can happen in other areas of my code. ...
7
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...
11
by: Colleyville Alan | last post by:
I posted that I was having trouble with a SQL statement that was working in the SQL window, but not in VBA. I have since discovered that when I create the string in VBA it is over 1023 characters...
3
by: Andy_Khosravi | last post by:
I have been trying to build a user friendly search engine for a small database I have created. I'm having some particular problems with one of my date fields. Here's the setup: I'm using...
9
by: Michael | last post by:
Hi all, I would like to get people's opinion about executing SQL statements in C# (or any other .NET language really). I used to create my SQL statement by building a string and replacing single...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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...

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.