asp_databases thread: select and getdate()
Message #1 by lodris@m... on Thu, 17 May 2001 18:18:30
|
|
i am trying to pull only the records that where inserted into the database
today but cant seem to get it working it only returns an empty set.My date
format is 05/17/01 in my database.Heres the code thats not working
properly.Does anyone know where im going wrong.
Thanks
Leigh
Set oRs = oConn.Execute("SELECT * From trade Where getday = getdate()")
Message #2 by Kyle Burns <kburns@c...> on Thu, 17 May 2001 12:47:06 -0500
|
|
GetDate() returns the date and time. Your query will only return the
records that GetDay equals the exact date and time the query is run.
You
will need to parse out the date/time to achieve the results you want or
use
the CONVERT function.
>> -----Original Message-----
>> From: lodris@m... [mailto:lodris@m...]
>> Sent: Thursday, May 17, 2001 1:19 PM
>> To: ASP Databases
>> Subject: [asp_databases] select and getdate()
>>
>>
>> i am trying to pull only the records that where inserted
>> into the database
>> today but cant seem to get it working it only returns an
>> empty set.My date
>> format is 05/17/01 in my database.Heres the code thats not working
>> properly.Does anyone know where im going wrong.
>> Thanks
>> Leigh
>>
>>
>>
>> Set oRs =3D oConn.Execute("SELECT * From trade Where getday
>> =3D getdate()")
>>
>>
>>
>>
Message #3 by Charlie McCormack <Charlie.McCormack@l...> on Fri, 18 May 2001 08:18:46 +1000
|
|
try this
SELECT * FROM trade WHERE getday =3D Now()
-----Original Message-----
From: lodris@m... [mailto:lodris@m...]
Sent: Friday, 18 May 2001 4:19 AM
To: ASP Databases
Subject: [asp_databases] select and getdate()
i am trying to pull only the records that where inserted into the database
t
oday but cant seem to get it working it only returns an empty set.My date
f
ormat is 05/17/01 in my database.Heres the code thats not working
properly.Does anyone know where im going wrong.
Thanks
Leigh
Set oRs =3D oConn.Execute("SELECT * From trade Where getday =3D getdate(
)")
Message #4 by "Noumaan Abubakar" <Noumaan_Abubakar@m...> on Fri, 18 May 2001 15:06:16
|
|
Leigh,
The problem of getting an empty record set is because your SQL statement
is incorrect.
Try:
SQLSTR = "Select * From trade Where getday = " & getdate
Set oRs = oConn.Execute(SQLSTR)
The problem is caused because you are using the getdate in the sql string.
I.e. rather than using the value returned from getdate, u are actually
using the value 'getdate' in the sql string.
Hope this helps u ot, or sorts ur problem out
Let me know if it works!!
Noumaan
Message #5 by "Ken Schaefer" <ken@a...> on Sun, 20 May 2001 18:45:07 +1000
|
|
GetDate() is a valid SQL Server function. If you are using SQL Server, and
pass GetDate as part of the SQL string, SQL Server will return the current
date/time
GetDate is *not* valid VBScript function.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: The problem of getting an empty record set is because your SQL statement
: is incorrect.
:
: Try:
:
: SQLSTR = "Select * From trade Where getday = " & getdate
: Set oRs = oConn.Execute(SQLSTR)
:
: The problem is caused because you are using the getdate in the sql string.
: I.e. rather than using the value returned from getdate, u are actually
: using the value 'getdate' in the sql string.
:
: Hope this helps u ot, or sorts ur problem out
:
: Let me know if it works!!
:
: Noumaan
Message #6 by "Ken Schaefer" <ken@a...> on Sun, 20 May 2001 18:47:35 +1000
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: i am trying to pull only the records that where inserted into the database
: today but cant seem to get it working it only returns an empty set.My date
: format is 05/17/01 in my database.Heres the code thats not working
: properly.Does anyone know where im going wrong.
:
: Set oRs = oConn.Execute("SELECT * From trade Where getday = getdate()")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SELECT *
FROM Trade
WHERE getday = CONVERT(varchar(20), GetDate(), 103)
Change 103 to the appropriate dd/mm/yy or mm/dd/yy etc for your table.
Cheers
Ken
|