|
 |
asp_databases thread: date functions
Message #1 by "Matthew Lohr" <mlohr@t...> on Sat, 10 Jun 2000 16:57:58 -0400
|
|
I am trying to do a date comparison. I need to evaluate if the date in the
database is greater than or less than the current date. My code seems to be
doing nothing at all except outputting the entire table. The code is as
follows
Dim current
current = Response.Write(date)
'Create our SQL statement variable
Dim strSQL
strSQL = "SELECT date, event, loccity, locstate FROM events WHERE date
GREATER '" & current & "%'" & _
" ORDER BY date"
Message #2 by "Ken Schaefer" <ken.s@a...> on Sun, 11 Jun 2000 23:07:11 +1000
|
|
datTemp = some_date_value_here
strSQL = "SELECT field1 "
strSQL = strSQL & "FROM table1 "
strSQL = strSQL & "WHERE date >= '" & datTemp & "' "
strSQL = strSQL & "ORDER BY date"
Another hint, don't call your field names words that might be reserved
words, like date, username, password etc - you just get yourself into
problems later on :-) You can make them more descriptive in the process by
calling them StartDate, EndDate, EnteredDate etc
Cheers
Ken
----- Original Message -----
From: "Matthew Lohr"
To: "ASP Databases" <asp_databases@p...>
Sent: Sunday, June 11, 2000 6:57 AM
Subject: [asp_databases] date functions
> I am trying to do a date comparison. I need to evaluate if the date in
the
> database is greater than or less than the current date. My code seems to
be
> doing nothing at all except outputting the entire table. The code is as
> follows
>
> Dim current
> current = Response.Write(date)
>
>
> 'Create our SQL statement variable
> Dim strSQL
> strSQL = "SELECT date, event, loccity, locstate FROM events WHERE date
> GREATER '" & current & "%'" & _
> " ORDER BY date"
>
>
Message #3 by "Rod Aubertin" <mcountry@n...> on Mon, 12 Jun 2000 07:56:23 -0400
|
|
In my dealings with SQL change the "GREATER" word for the sign ">" and this
should work.
You might have to include the "#" before and after your variable so that the
SQL knows it's a date variable.
It should look like this:
strSQL = "SELECT date, event, loccity, locstate FROM events WHERE date
> # " & current & " # " & _
" ORDER BY date"
Rod Aubertin
Programmer/Analyst
RBB Innovations Ltd.
webmstr@r...
-----Original Message-----
From: Matthew Lohr
Sent: Saturday, June 10, 2000 4:58 PM
To: ASP Databases
Subject: [asp_databases] date functions
I am trying to do a date comparison. I need to evaluate if the date in the
database is greater than or less than the current date. My code seems to be
doing nothing at all except outputting the entire table. The code is as
follows
Dim current
current = Response.Write(date)
'Create our SQL statement variable
Dim strSQL
strSQL = "SELECT date, event, loccity, locstate FROM events WHERE date
GREATER '" & current & "%'" & _
" ORDER BY date"
Message #4 by "Matthew Lohr" <mlohr@t...> on Mon, 12 Jun 2000 12:20:38 -0400
|
|
I get an unterminated string constant error with this statement. I tried
playing with it a little bit but can't quite get it straight
-----Original Message-----
From: Rod Aubertin
Sent: Monday, June 12, 2000 7:56 AM
To: ASP Databases
Subject: [asp_databases] RE: date functions
In my dealings with SQL change the "GREATER" word for the sign ">" and this
should work.
You might have to include the "#" before and after your variable so that the
SQL knows it's a date variable.
It should look like this:
strSQL = "SELECT date, event, loccity, locstate FROM events WHERE date
> # " & current & " # " & _
" ORDER BY date"
Rod Aubertin
Programmer/Analyst
RBB Innovations Ltd.
webmstr@r...
-----Original Message-----
From: Matthew Lohr
Sent: Saturday, June 10, 2000 4:58 PM
To: ASP Databases
Subject: [asp_databases] date functions
I am trying to do a date comparison. I need to evaluate if the date in the
database is greater than or less than the current date. My code seems to be
doing nothing at all except outputting the entire table. The code is as
follows
Dim current
current = Response.Write(date)
'Create our SQL statement variable
Dim strSQL
strSQL = "SELECT date, event, loccity, locstate FROM events WHERE date
GREATER '" & current & "%'" & _
" ORDER BY date"
Message #5 by "Ken Schaefer" <ken.s@a...> on Tue, 13 Jun 2000 19:01:58 +1000
|
|
Probably because the code wrapped around onto another line, and you didn't
unwrap it.
Use this instead (this is slightly better coding style)
strSQL = "SELECT date, event, loccity, locstate "
strSQL = strSQL & "FROM events "
strSQL = strSQL & "WHERE date > #" & current & "# "
strSQL = strSQL & "ORDER BY date"
PS you should NEVER give columns and tables names like "date" - Date is a
reserved word in many, many things...change it to something else and avoid
the future headaches.
Cheers
Ken
----- Original Message -----
From: "Matthew Lohr"
To: "ASP Databases" <asp_databases@p...>
Sent: Tuesday, June 13, 2000 2:20 AM
Subject: [asp_databases] RE: date functions
> I get an unterminated string constant error with this statement. I tried
> playing with it a little bit but can't quite get it straight
> -----Original Message-----
> From: Rod Aubertin
> Sent: Monday, June 12, 2000 7:56 AM
> To: ASP Databases
> Subject: [asp_databases] RE: date functions
>
>
> In my dealings with SQL change the "GREATER" word for the sign ">" and
this
> should work.
>
> You might have to include the "#" before and after your variable so that
the
> SQL knows it's a date variable.
>
> It should look like this:
>
> strSQL = "SELECT date, event, loccity, locstate FROM events WHERE date
> > # " & current & " # " & _
> " ORDER BY date"
>
> Rod Aubertin
> Programmer/Analyst
> RBB Innovations Ltd.
> webmstr@r...
>
|
|
 |