ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old November 4th, 2009, 05:28 AM
alphatester alphatester is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2009
Posts: 81 alphatester User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 7 m 15 sec
Reputation Power: 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...

Reply With Quote
  #2  
Old November 4th, 2009, 05:39 AM
new learner new learner is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Location: India
Posts: 296 new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 5 Days 7 h 25 m 25 sec
Reputation Power: 127
Quote:
Originally Posted by alphatester
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...


Hi,

Not very sure but should < not be =

Apologies if i am thinking wrongly.

Regards

Reply With Quote
  #3  
Old November 4th, 2009, 05:43 AM
alphatester alphatester is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2009
Posts: 81 alphatester User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 7 m 15 sec
Reputation Power: 1
hmm, not sure - would that not return only exact matches? (ie posts made exactly the same second as 24hrs ago)

Reply With Quote
  #4  
Old November 4th, 2009, 05:52 AM
new learner new learner is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Location: India
Posts: 296 new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 5 Days 7 h 25 m 25 sec
Reputation Power: 127
Quote:
Originally Posted by alphatester
hmm, not sure - would that not return only exact matches? (ie posts made exactly the same second as 24hrs ago)


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

Reply With Quote
  #5  
Old November 4th, 2009, 05:58 AM
micky's Avatar
micky micky is offline
Couch Potato Wizard
Click here for more information. Click here for more information
 
Join Date: Jan 2005
Location: India
Posts: 12,259 micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)  Folding Points: 1480 Folding Title: Novice Folder
Time spent in forums: 5 Months 4 Days 2 m 48 sec
Reputation Power: 2179
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.
__________________
Laziness is my religion and Sunday is my God

Get the Mantra!

Reply With Quote
  #6  
Old November 4th, 2009, 06:00 AM
alphatester alphatester is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2009
Posts: 81 alphatester User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 7 m 15 sec
Reputation Power: 1
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"

Reply With Quote
  #7  
Old November 4th, 2009, 06:14 AM
micky's Avatar
micky micky is offline
Couch Potato Wizard
Click here for more information. Click here for more information
 
Join Date: Jan 2005
Location: India
Posts: 12,259 micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)  Folding Points: 1480 Folding Title: Novice Folder
Time spent in forums: 5 Months 4 Days 2 m 48 sec
Reputation Power: 2179
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.

Reply With Quote
  #8  
Old November 4th, 2009, 07:04 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 48th Plane (28500 - 28999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 28,838 Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)  Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 3 Months 2 Weeks 1 Day 14 h 30 m 10 sec
Reputation Power: 2389
what is your database? Access? SQL Server?

Reply With Quote
  #9  
Old November 4th, 2009, 07:29 AM
alphatester alphatester is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2009
Posts: 81 alphatester User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 7 m 15 sec
Reputation Power: 1
Hi shadow - sql server 2000

Reply With Quote
  #10  
Old November 4th, 2009, 08:43 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 3,461 sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 1 Day 16 h 50 m 26 sec
Reputation Power: 1806
Quote:
Originally Posted by alphatester
Hi shadow - sql server 2000


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"
Comments on this post
Shadow Wizard agrees: yep that's my idea too
new learner agrees: Thanks sync

Reply With Quote
  #11  
Old November 5th, 2009, 04:08 AM
alphatester alphatester is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2009
Posts: 81 alphatester User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 7 m 15 sec
Reputation Power: 1
Have tested this - works perfectly! Thanks very much sync or swim!

Reply With Quote
  #12  
Old November 5th, 2009, 05:33 AM
new learner new learner is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Location: India
Posts: 296 new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 5 Days 7 h 25 m 25 sec
Reputation Power: 127
Quote:
Originally Posted by alphatester
Have tested this - works perfectly! Thanks very much sync or swim!


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

Reply With Quote
  #13  
Old November 5th, 2009, 06:43 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 48th Plane (28500 - 28999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 28,838 Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)  Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 3 Months 2 Weeks 1 Day 14 h 30 m 10 sec
Reputation Power: 2389
Quote:
Originally Posted by new learner
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
it's the same thing, one day is 24 hours.
it's like the difference between:
Code:
x = 10 + 5

and:
Code:
x = 5 +5 + 5


Reply With Quote
  #14  
Old November 6th, 2009, 06:59 AM
new learner new learner is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Location: India
Posts: 296 new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level)new learner User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 5 Days 7 h 25 m 25 sec
Reputation Power: 127
Quote:
Originally Posted by Shadow Wizard
it's the same thing, one day is 24 hours.
it's like the difference between:
Code:
x = 10 + 5

and:
Code:
x = 5 +5 + 5



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

Reply With Quote
  #15  
Old November 6th, 2009, 11:41 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 48th Plane (28500 - 28999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 28,838 Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)  Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 3 Months 2 Weeks 1 Day 14 h 30 m 10 sec
Reputation Power: 2389
Quote:
Originally Posted by new learner
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
it will be the same data, because those two things are the same, they're
simply two ways to write the same thing.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingASP Development > Simple ASP script isn't working...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek