|
 |
asp_databases thread: Getting Current Records
Message #1 by kalyan_ramji@h... on Mon, 23 Jul 2001 15:13:57
|
|
Hi,
I have a date field in my table and I am trying to get the records for the
past 30 days from the entire set in the database. I am not sure as to how
I should pace my sql statement to get records just for the last 30 days
and not all of them.
Thanks for all your help..
Message #2 by "Eoghan O'Byrne" <Eoghan.O'Byrne@W...> on Mon, 23 Jul 2001 15:33:19 +0100
|
|
Hey Kalyan,
I'm sure exactly what you want but try this,
SELECT * FROM table WHERE date_column > (getdate() - 30)
Im not sure if the getdate() function works with Access if thats what
your using. If not use a Javascript / Vbscript script to get the date.
Or if you only want to run this once you can secify the date eg.
SELECT * FROM table WHERE date_column > '07/23/01'
Hope this helps,
Regards,
Eoghan
-----Original Message-----
From: kalyan_ramji@h... [mailto:kalyan_ramji@h...]
Sent: Monday, July 23, 2001 4:14 PM
To: ASP Databases
Subject: [asp_databases] Getting Current Records
Hi,
I have a date field in my table and I am trying to get the records for
the
past 30 days from the entire set in the database. I am not sure as to
how
I should pace my sql statement to get records just for the last 30 days
and not all of them.
Thanks for all your help..
Message #3 by "Eoghan O'Byrne" <Eoghan.O'Byrne@W...> on Mon, 23 Jul 2001 15:35:00 +0100
|
|
Oops,
I meant for specifying a date enter the date of 30 days ago eg.
SELECT * FROM table WHERE date_column > '23/06/01'
Regards,
Eoghan
-----Original Message-----
From: kalyan_ramji@h... [mailto:kalyan_ramji@h...]
Sent: Monday, July 23, 2001 4:14 PM
To: ASP Databases
Subject: [asp_databases] Getting Current Records
Hi,
I have a date field in my table and I am trying to get the records for
the
past 30 days from the entire set in the database. I am not sure as to
how
I should pace my sql statement to get records just for the last 30 days
and not all of them.
Thanks for all your help..
Message #4 by kalyan_ramji@h... on Mon, 23 Jul 2001 16:19:11
|
|
Thanks Eoghan,
The Date() function works instead of the GetDate(). Thanks for your help.
> Oops,
>
> I meant for specifying a date enter the date of 30 days ago eg.
>
> SELECT * FROM table WHERE date_column > '23/06/01'
>
> Regards,
>
> Eoghan
>
> -----Original Message-----
> From: kalyan_ramji@h... [mailto:kalyan_ramji@h...]
> Sent: Monday, July 23, 2001 4:14 PM
> To: ASP Databases
> Subject: [asp_databases] Getting Current Records
>
>
> Hi,
>
> I have a date field in my table and I am trying to get the records for
> the
> past 30 days from the entire set in the database. I am not sure as to
> how
> I should pace my sql statement to get records just for the last 30
days
> and not all of them.
>
> Thanks for all your help..
>
>
Message #5 by "Drew, Ron" <RDrew@B...> on Mon, 23 Jul 2001 11:21:28 -0400
|
|
If MS Access....
WHERE date_column between Now()-30 and Now()
If MS SQL....
WHERE DATEDIFF(DAY,date_column,GETDATE()) <=3D 30
-----Original Message-----
From: Eoghan O'Byrne [mailto:Eoghan.O'Byrne@W...]
Sent: Monday, July 23, 2001 10:33 AM
To: ASP Databases
Subject: [asp_databases] RE: Getting Current Records
Hey Kalyan,
I'm sure exactly what you want but try this,
SELECT * FROM table WHERE date_column > (getdate() - 30)
Im not sure if the getdate() function works with Access if thats what
your using. If not use a Javascript / Vbscript script to get the date.
Or if you only want to run this once you can secify the date eg.
SELECT * FROM table WHERE date_column > '07/23/01'
Hope this helps,
Regards,
Eoghan
-----Original Message-----
From: kalyan_ramji@h... [mailto:kalyan_ramji@h...]
Sent: Monday, July 23, 2001 4:14 PM
To: ASP Databases
Subject: [asp_databases] Getting Current Records
Hi,
I have a date field in my table and I am trying to get the records for
the
past 30 days from the entire set in the database. I am not sure as to
how
I should pace my sql statement to get records just for the last 30 days
and not all of them.
Thanks for all your help..
Message #6 by "Taher Moiyed" <taherm@f...> on Tue, 24 Jul 2001 09:19:52 +0100
|
|
Hi kalyan
ths can be achieved by many ways. the most easiest is to use microsoft
access query builder. and then drop teh field which you want to view and in
teh criteria section write >now between (now()-30
check teh results
something like taht and try to view the sql syntax of it copy that sql
syntax and paste it into your code it will work fine.
i have done the same for one of my project and it wors fine here is teh code
for it
SELECT [HostingDetails].[CompanyName], [HostingDetails].[DomainAddress],
[HostingDetails].[webrenewdate], [HostingDetails].[WebspaceRenewalCost]
FROM HostingDetails
WHERE ((([HostingDetails].[webrenewdate])>Date() And
([HostingDetails].[webrenewdate])<Date()+30))
or you could use qraphical query bulider in sql server
-----Original Message-----
From: kalyan_ramji@h... [mailto:kalyan_ramji@h...]
Sent: 23 July 2001 15:14
To: ASP Databases
Subject: [asp_databases] Getting Current Records
Hi,
I have a date field in my table and I am trying to get the records for the
past 30 days from the entire set in the database. I am not sure as to how
I should pace my sql statement to get records just for the last 30 days
and not all of them.
Thanks for all your help..
|
|
 |