Wrox Programmer Forums
|
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
 
Old November 7th, 2006, 02:02 AM
Authorized User
 
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
 
Old November 7th, 2006, 09:36 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

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
 
Old November 7th, 2006, 10:40 AM
Authorized User
 
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

any date the is the nearest to the current date

-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
 
Old November 7th, 2006, 10:46 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

....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
 
Old November 7th, 2006, 10:48 AM
Authorized User
 
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Within the current month


Thanx

-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
 
Old November 7th, 2006, 10:53 AM
Authorized User
 
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old November 7th, 2006, 02:51 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

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
 
Old November 7th, 2006, 03:02 PM
Authorized User
 
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The DATEADD function does not work in MS Access, does it?

-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
 
Old November 7th, 2006, 03:19 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

It does, but I am not sure if you can use it in a straight query like above but check out these links.

http://www.techonthenet.com/access/f...te/dateadd.php
http://experts.about.com/q/Using-MS-...40/DateAdd.htm
http://www.tek-tips.com/faqs.cfm?fid=4230

-------------------------
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





Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP to query a SQL recursive tree chame Classic ASP Basics 4 April 10th, 2012 07:59 PM
Using ORDER BY in SQL query in ASP page saifi4u Classic ASP Databases 1 February 29th, 2008 09:19 AM
sql query in asp graph mateenmohd Classic ASP Professional 6 August 6th, 2007 01:14 AM
ASP- SQL Server..Query help.... cancer10 Classic ASP Databases 5 February 1st, 2007 06:26 AM
Sql Query in ASP mateenmohd SQL Server 2000 3 October 29th, 2003 12:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.