Solved

Time/Date Query

Posted on 2016-09-26
11
37 Views
Last Modified: 2016-09-27
Hi there, I am not sure if this is correct or not...

Set CheckCurrency=oConn.Execute("SELECT * FROM site_curr WHERE curr_update=<#"&Now()&"# AND curr_uptime=<#"&Time()+1&"#")

Open in new window


What I want to do is check if these values is more than 1 hour old from the values in the DB

eg if it is 10am, are the values prior to 9am (that same day)

Any help is appreciated
0
Comment
Question by:Graeme
  • 6
  • 4
11 Comments
 
LVL 32

Assisted Solution

by:Big Monty
Big Monty earned 100 total points
ID: 41816486
try:

Set CheckCurrency=oConn.Execute("SELECT * FROM site_curr WHERE curr_update=<#"&Now()&"# AND curr_uptime=<#DateAdd( "h", "Now()" 1 )#")
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 41817145
what's your database? Access?
0
 

Author Comment

by:Graeme
ID: 41817250
Hi Ryan, yes Access 2003

BigMonty, trying your code, got this error:
Expected ')'

/home.asp, line 112

Set CheckCurrency=oConn.Execute("SELECT * FROM site_curr WHERE curr_update=<#"&Now()&"# AND curr_uptime=<#DateAdd( "h", "Now()" 1 )#")

Open in new window

Points to the h in DateAdd
0
 
LVL 49

Assisted Solution

by:Ryan Chong
Ryan Chong earned 400 total points
ID: 41817308
in access you can try use DateDiff function to get the datetime difference:

DateDiff Function
https://support.office.com/en-us/article/DateDiff-Function-e6dd7ee6-3d01-4531-905c-e24fc238f85f

to get records which are more than 1 hour old from the values in the DB, you can try:
....
Where DateDiff ( 'n', curr_update, now)  >60

Open in new window

hence:
Set CheckCurrency=oConn.Execute("SELECT * FROM site_curr WHERE DateDiff ( 'n', curr_update, now)  >60")

Open in new window

if got record(s) returned, it means got record(s) is more than 1 hour old.
0
 

Author Comment

by:Graeme
ID: 41817314
Looks very promising

And from here, I would use this IF statement to execute if it is outside 60min old?

If Not CheckCurrency.EOF Then

Open in new window

?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 49

Accepted Solution

by:
Ryan Chong earned 400 total points
ID: 41817318
And from here, I would use this IF statement to execute if it is outside 60min old?
yup, like:
Set CheckCurrency=oConn.Execute("SELECT * FROM site_curr WHERE DateDiff ( 'n', curr_update, now)  >60")

If Not CheckCurrency.EOF Then
    response.write "at least 1 hour old record was found"
else
    response.write "no 1 hour old record was found"
end if

Open in new window

you can also do a Count in your SQL statement if necessary or adding Top 1 into your Select statement above if you just want to check the existence of record.
0
 

Author Comment

by:Graeme
ID: 41817329
Cheers for that, work great! (by itself)

In reference to one of our previous questions (aspJSON), when we add this query & If statement, would there be any reason why aspJSON now become an error?

It does not error when the If statement and query commented out or if aspJSON isnt within the If statement, but within it errors, cannot figure out why
Class aspJSON

Open in new window

0
 

Author Comment

by:Graeme
ID: 41817330
Change the name of the page to:

http://dev.gptouring.com.au/currAPI.asp (same user and pw)
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 41817339
when we add this query & If statement, would there be any reason why aspJSON now become an error?
it shouldn't happened as both are not really "related" to each other. need to know the error message you encountered.

if it's a totally separate question, perhaps we can follow up in another new thread instead? so it's more likely to be traceable cheers.
0
 

Author Comment

by:Graeme
ID: 41817340
Yes of course, I will start another thread for it

Cheers
0
 

Author Comment

by:Graeme
ID: 41817347
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to remove Duplicates from Generic List in Csharp 5 77
Classic ASP + JS 4 81
SMS AddAttachment Protocol Error Classic ASP 10 36
Recordset containing single quotes 8 23
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now