|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Simple ASP script isn't working...
OneDayAgo = now()-1
sql = "SELECT * FROM Content WHERE publishDate <'"&OneDayAgo&"' ORDER BY PublishDate ASC" set rs = objConn.execute(SQL) Why does this not return articles published in the last 24hrs? I either get everything or nothing depending on the direction the < is pointing. publishdate is just a standard datetime db column... ![]() |
|
#2
|
|||
|
|||
|
Quote:
Hi, Not very sure but should < not be = Apologies if i am thinking wrongly. Regards |
|
#3
|
|||
|
|||
|
hmm, not sure - would that not return only exact matches? (ie posts made exactly the same second as 24hrs ago)
|
|
#4
|
|||
|
|||
|
Quote:
Ya agree, it could be the case, am not able to check out at my end for lack of such data; don't know whether something like this where Date between '" & DateFrom & "' and '" & DateTo & "' can be helpful. Let us wait for a while, the gurus will come by Regards |
|
#5
|
||||
|
||||
|
What exactly do you want here??
Your query will get all records for which publishDate is less than yesterday and NOT last 24 hours records. If you want last 24 hours records then you'll something like new learner is suggesting. |
|
#6
|
|||
|
|||
|
Hi Micky,
So by that logic would this not get the last 24 hrs? sql = "SELECT * FROM Content WHERE publishDate >'"&OneDayAgo&"' ORDER BY PublishDate ASC" |
|
#7
|
||||
|
||||
|
No, it will show whose records whose date is greater than yesterday.
If you have records in database whose date is bigger than today or may be week later...... then you'll get all those records. |
|
#8
|
||||
|
||||
|
what is your database? Access? SQL Server?
|
|
#9
|
|||
|
|||
|
Hi shadow - sql server 2000
|
|
#10
|
||||
|
||||
|
Quote:
I think SQLServer has native commands for adding dates so you could try something liek this: Code:
sql = "SELECT * FROM Content WHERE publishDate >= DateAdd(day, -1, getDate()) ORDER BY PublishDate ASC" |
|
#11
|
|||
|
|||
|
Have tested this - works perfectly! Thanks very much sync or swim!
![]() |
|
#12
|
|||
|
|||
|
Quote:
Hi Sync, Just for my info If instead of sql = "SELECT * FROM Content WHERE publishDate >= DateAdd(day, -1, getDate()) ORDER BY PublishDate ASC" I have sql = "SELECT * FROM Content WHERE publishDate >= DateAdd(h, -24, getDate()) ORDER BY PublishDate ASC" what kind of output can be expected or is it not possible. Thanks |
|
#13
|
||||
|
||||
|
Quote:
it's like the difference between: Code:
x = 10 + 5 and: Code:
x = 5 +5 + 5 ![]() |
|
#14
|
|||
|
|||
|
Quote:
Thanks shadow; I was just wondering whether in the case of (day,-1,GetDate()) will the output be all data corresponding to the previous day's date & in case of (h,-24,GetDate()) will the output be all data corresponding to the 24 hrs from the current date & time. Thanks |
|
#15
|
||||
|
||||
|
Quote:
simply two ways to write the same thing. |
![]() |
| Viewing: ASP Free Forums > Programming > ASP Development > Simple ASP script isn't working... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|