ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to extract data through ODBC with date criteria? (https://www.excelbanter.com/excel-programming/283180-how-extract-data-through-odbc-date-criteria.html)

dchow

How to extract data through ODBC with date criteria?
 
There is a table in the database with separate fields Month and Year
as integers. How to use SQL to retrieve records after a specified
date? I have tried a number of date functions e.g. DateSerial but SQL
doesn't like it. How should I specify that condition?

Ken Dales

How to extract data through ODBC with date criteria?
 
Let's say you want records from dates after March 2002;
you could try this:

SELECT * FROM MY_TABLE WHERE (YEAR 2002) OR (YEAR=2002
and MONTH3)

Just substitute in the proper parameters to allow
selection of any month and year.

-----Original Message-----
There is a table in the database with separate fields

Month and Year
as integers. How to use SQL to retrieve records after a

specified
date? I have tried a number of date functions e.g.

DateSerial but SQL
doesn't like it. How should I specify that condition?
.


dchow

How to extract data through ODBC with date criteria?
 
Thanks.
I was thinking of converting the Month and Year to a date and then use
any date comparison method.
Yours is simple enough.


On Fri, 21 Nov 2003 06:37:05 -0800, "Ken Dales"
wrote:

Let's say you want records from dates after March 2002;
you could try this:

SELECT * FROM MY_TABLE WHERE (YEAR 2002) OR (YEAR=2002
and MONTH3)

Just substitute in the proper parameters to allow
selection of any month and year.

-----Original Message-----
There is a table in the database with separate fields

Month and Year
as integers. How to use SQL to retrieve records after a

specified
date? I have tried a number of date functions e.g.

DateSerial but SQL
doesn't like it. How should I specify that condition?
.



Ken Dales

How to extract data through ODBC with date criteria?
 
Sometimes simple is best, but our minds get used to
thinking too concretely: it's a date, so I have to use
date functions!

-----Original Message-----
Thanks.
I was thinking of converting the Month and Year to a date

and then use
any date comparison method.
Yours is simple enough.


On Fri, 21 Nov 2003 06:37:05 -0800, "Ken Dales"
wrote:

Let's say you want records from dates after March 2002;
you could try this:

SELECT * FROM MY_TABLE WHERE (YEAR 2002) OR (YEAR=2002
and MONTH3)

Just substitute in the proper parameters to allow
selection of any month and year.

-----Original Message-----
There is a table in the database with separate fields

Month and Year
as integers. How to use SQL to retrieve records after a

specified
date? I have tried a number of date functions e.g.

DateSerial but SQL
doesn't like it. How should I specify that condition?
.


.



All times are GMT +1. The time now is 01:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com