Database query 1

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Good Morning, Is it possible to use the DRW to filter queries using the
timestamp? Ie: Only display files which meet the criteria of timestamp - 30
days.

I imagine it would be an sql as follows: s-sql="SELECT * FROM Results WHERE
timestamp = timestamp <30. but obvviously that won't work. Is there a code
that will give me what I want?
 
s-sql="SELECT * FROM Results WHERE timestamp<#" & DateAdd("d",-30,Date()) & "#"
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


| Good Morning, Is it possible to use the DRW to filter queries using the
| timestamp? Ie: Only display files which meet the criteria of timestamp - 30
| days.
|
| I imagine it would be an sql as follows: s-sql="SELECT * FROM Results WHERE
| timestamp = timestamp <30. but obvviously that won't work. Is there a code
| that will give me what I want?
|
 
Hi Stefan, Did not seem to work, sorry! - pasted it in exactly and then
tried putting [] around Timestamp but no go.

I would also like to add it to a existing query: s-sql="SELECT * FROM
Results WHERE Sector= 'Company'<br>ORDER BY Results.ID DESC;<br>"

Appreciate your help.
 
Usually for this type of query it's easier to do everything in the sql. So
to get records where timestamp is within the last 30 days

SELECT *
FROM Table
where datediff('d', TimeStamp, date()) <= 30

Or if you subtract a number from a date, the number is taken to be days so
we can do
SELECT *
FROM Table
where TimeStamp >= date() - 30

Cheers,
Jon
 
Yep, That's got it Jon, Thanks - now, how do I include it in an existing
query?:

s-sql="SELECT * FROM
Results WHERE Sector= 'Company'<br>ORDER BY Results.ID DESC;<br>"

Thanks, Raymondo

Jon Spivey said:
Usually for this type of query it's easier to do everything in the sql. So
to get records where timestamp is within the last 30 days

SELECT *
FROM Table
where datediff('d', TimeStamp, date()) <= 30

Or if you subtract a number from a date, the number is taken to be days so
we can do
SELECT *
FROM Table
where TimeStamp >= date() - 30

Cheers,
Jon


Stefan B Rusynko said:
s-sql="SELECT * FROM Results WHERE timestamp<#" & DateAdd("d",-30,Date())
& "#"
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


| Good Morning, Is it possible to use the DRW to filter queries using
the
| timestamp? Ie: Only display files which meet the criteria of
timestamp - 30
| days.
|
| I imagine it would be an sql as follows: s-sql="SELECT * FROM Results
WHERE
| timestamp = timestamp <30. but obvviously that won't work. Is there a
code
| that will give me what I want?
|
 
Hi,
Something along these lines

SELECT *
FROM Results
WHERE (Sector= 'Company') AND ([TimeStamp] >= date() - 30)

You can just stick that in the custom query box of the wizard

Cheers,
Jon



Raymondo said:
Yep, That's got it Jon, Thanks - now, how do I include it in an existing
query?:

s-sql="SELECT * FROM
Results WHERE Sector= 'Company'<br>ORDER BY Results.ID DESC;<br>"

Thanks, Raymondo

Jon Spivey said:
Usually for this type of query it's easier to do everything in the sql.
So
to get records where timestamp is within the last 30 days

SELECT *
FROM Table
where datediff('d', TimeStamp, date()) <= 30

Or if you subtract a number from a date, the number is taken to be days
so
we can do
SELECT *
FROM Table
where TimeStamp >= date() - 30

Cheers,
Jon


Stefan B Rusynko said:
s-sql="SELECT * FROM Results WHERE timestamp<#" &
DateAdd("d",-30,Date())
& "#"
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


| Good Morning, Is it possible to use the DRW to filter queries using
the
| timestamp? Ie: Only display files which meet the criteria of
timestamp - 30
| days.
|
| I imagine it would be an sql as follows: s-sql="SELECT * FROM Results
WHERE
| timestamp = timestamp <30. but obvviously that won't work. Is there
a
code
| that will give me what I want?
|
 
Create a custom query throgh the database result wizard....? See Jon's
other response for the query code.

Raymondo said:
Yep, That's got it Jon, Thanks - now, how do I include it in an existing
query?:

s-sql="SELECT * FROM
Results WHERE Sector= 'Company'<br>ORDER BY Results.ID DESC;<br>"

Thanks, Raymondo

Jon Spivey said:
Usually for this type of query it's easier to do everything in the sql.
So
to get records where timestamp is within the last 30 days

SELECT *
FROM Table
where datediff('d', TimeStamp, date()) <= 30

Or if you subtract a number from a date, the number is taken to be days
so
we can do
SELECT *
FROM Table
where TimeStamp >= date() - 30

Cheers,
Jon


Stefan B Rusynko said:
s-sql="SELECT * FROM Results WHERE timestamp<#" &
DateAdd("d",-30,Date())
& "#"
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


| Good Morning, Is it possible to use the DRW to filter queries using
the
| timestamp? Ie: Only display files which meet the criteria of
timestamp - 30
| days.
|
| I imagine it would be an sql as follows: s-sql="SELECT * FROM Results
WHERE
| timestamp = timestamp <30. but obvviously that won't work. Is there
a
code
| that will give me what I want?
|
 
Back
Top