Forums

This topic is locked

Help Please with Date Extraction

Posted 06 Mar 2001 12:22:41
1
has voted
06 Mar 2001 12:22:41 Phil Cue posted:
Hi don’t know if you can help, but here goes...

I want to pull product data from a database to a results page, however this result data needs to be split using the date data (probably by 2 recordsets) to show result for latest products 30 days or earlier and then another for 31-90 days. How can I display product data so it displays 30 days or earlier and then another for 31-90 days when date data is, for example 01.03.01, 12.02.01, etc?!

Visualise it: From a search for Products a results page shows two tables with results as 1. Products up to 30 days old and 2. 31-90 old.

Please let me know if you know!! Thanks.



Replies

Replied 07 Mar 2001 19:34:12
07 Mar 2001 19:34:12 George Petrov replied:
You should use the DATEDIFF command in your SQL statement used on the Recordset query. For example:

SELECT .... FROM ... WHERE DATEDIFF(m,date_field,GETDATE()) <= 3

Will give you the items with date_field value within the last 3 months.

SELECT .... FROM ... WHERE DATEDIFF(m,date_field,GETDATE()) > 3 AND DATEDIFF(m,date_field,GETDATE()) <= 6

Will give you the records between 3 and 6 months old.

You can read more on DATEDIFF on msdn.microsoft.com/library/psdk/sql/ts_da-db_5vxi.htm




Greetings,
George Petrov
www.UDzone.com
Replied 21 Mar 2001 12:12:17
21 Mar 2001 12:12:17 Phil Cue replied:
Hmmmm.....

I am trying to collect 'Date of Offer' date information (upto 30 days
then 31-90 as mentioned) from an access database (locally, then eventually
from a MYSQL database for online) from the search page. But I get errors????

I can send you the page again to show you if you get a moment. Any further help you can give would be appreciated. Thanks.

Regards.

Replied 21 Mar 2001 12:17:03
21 Mar 2001 12:17:03 George Petrov replied:
In Access you should use DATE() insetad of GETDATE()
GETDATE is SQL Server only - don't know about MySQL - maybe its GETDATE in there too.

Greetings,
George Petrov
www.UDzone.com
Replied 22 Mar 2001 22:31:13
22 Mar 2001 22:31:13 Phil Cue replied:
Yes thanks George, I had read about that so tried it, but somewhere I am doing something wrong...

Replied 09 Apr 2001 14:53:54
09 Apr 2001 14:53:54 Phil Cue replied:
I have got no further with this and need to. If anyone else can help I'd appreciate it. Thanks.

Reply to this topic