 |
| Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

November 7th, 2006, 02:02 AM
|
|
Authorized User
|
|
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Sql Query Help - ASP
Hello,
I am developing a simple calender in ASP which will display the next upcoming birthday of my member. Just like some forum have.
I have a table which has 2 column
cname | dob
-------------------
Joe | 9/12/1982
Mathew | 2/17/1997
Pat | 8/23/1880
-------------------
What SQL Query should I use to get the name of that person?
[u]Some basic information:
</u>
Database = Access (may be I can upgrade it into SQL Server 2000)
Date Format in database = mm/dd/yyyy
-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
__________________
-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
|
|

November 7th, 2006, 09:36 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
Your question is to broad, what is your definition of "next upcoming birthday"? Is that 1 day, 2 days, or??
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
|

November 7th, 2006, 10:40 AM
|
|
Authorized User
|
|
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
any date the is the nearest to the current date
-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
|
|

November 7th, 2006, 10:46 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
....define NEAR? is that all birthdays for the current month, birthdays within 2 weeks of todays date?
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
|

November 7th, 2006, 10:48 AM
|
|
Authorized User
|
|
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Within the current month
Thanx
-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
|
|

November 7th, 2006, 10:53 AM
|
|
Authorized User
|
|
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
and if it does not find any b'day within the current month then it will look in teh next month, and so on...
-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
|
|

November 7th, 2006, 02:51 PM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
In MSSQL I would use the DATEADD([month, year, or day], n, getDate()) however, what you are asking is slightly a bit more complex;
For just the current month you coudl do something like
SELECT [data] FROM [table] WHERE dob BETWEEN getdate() AND DateAdd(month, 1, getDate())
but now, if the Row Count == 0 you want to do
SELECT [data] FROM [table] WHERE dob BETWEEN getdate() AND DateAdd(month, 2, getDate())
and so on.
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
|

November 7th, 2006, 03:02 PM
|
|
Authorized User
|
|
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
The DATEADD function does not work in MS Access, does it?
-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
|
|
 |