|
 |
asp_databases thread: Re: Help with a SQL Query
Message #1 by "Chip Dukes" <cdukes77@b...> on Mon, 13 May 2002 11:52:49 -0400
|
|
I figured out the answer - and yes it was as simple as I thought it should
be ... I'll post the answer just in case someone else has a brain hiccup
like I did ...
sqlString = "SELECT * FROM Member WHERE month(DOB) = " & Month(Date) & " and
day(DOB) = " & Day(Date)
Chip Dukes
----- Original Message -----
From: <cdukes77@b...>
To: "ASP Databases" <asp_databases@p...>
Sent: Sunday, May 19, 2002 3:42 PM
Subject: [asp_databases] Help with a SQL Query
> I'm kicking myself for not knowing this ... it seems like such a simple
> idea ... I must be missing something ...
>
> I have a SQL Server database with a DOB column (date of birth). The data
> is stored as a datetime datatype. All values are in the format 5/24/1955.
> I'm trying to find everybody whose birthday is today.
>
> There has to be a simple SQL query that will accomplish this.
>
> I started with the simple ...
>
> sqlString = "SELECT * FROM Member WHERE DOB = '" & Date & "'"
>
> which, of course, won't work. But I can't for the life of me figure out
> what will.
>
> Any help appreciated.
>
> Chip Dukes
>
Message #2 by cdukes77@b... on Sun, 19 May 2002 15:42:29
|
|
I'm kicking myself for not knowing this ... it seems like such a simple
idea ... I must be missing something ...
I have a SQL Server database with a DOB column (date of birth). The data
is stored as a datetime datatype. All values are in the format 5/24/1955.
I'm trying to find everybody whose birthday is today.
There has to be a simple SQL query that will accomplish this.
I started with the simple ...
sqlString = "SELECT * FROM Member WHERE DOB = '" & Date & "'"
which, of course, won't work. But I can't for the life of me figure out
what will.
Any help appreciated.
Chip Dukes
Message #3 by "Ken Schaefer" <ken@a...> on Tue, 21 May 2002 16:53:56 +1000
|
|
Since you're using SQL Server, you could do this like:
strSQL = _
"SELECT field1, field2, field3 " & _
"FROM Member " & _
"WHERE Month(DoB) = Month(GetDate()) " & _
"AND Day(DOB) = Day(GetDate())"
There's no need to involve VBScript at all.
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Chip Dukes" <cdukes77@b...>
Subject: [asp_databases] Re: Help with a SQL Query
: I figured out the answer - and yes it was as simple as I thought it should
: be ... I'll post the answer just in case someone else has a brain hiccup
: like I did ...
:
: sqlString = "SELECT * FROM Member WHERE month(DOB) = " & Month(Date) & "
and
: day(DOB) = " & Day(Date)
:
: Chip Dukes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
 |