Focal Point
[SOLVED] Current Date Minus x DAYS

This topic can be found at:
http://forums.informationbuilders.com/eve/forums/a/tpc/f/1381057331/m/427104591

July 30, 2009, 03:01 PM
bcook278
[SOLVED] Current Date Minus x DAYS
I have a very basic SQL statement that I am trying to run via DMC.

SELECT T1.DATE_STAMP FROM DATE_DIM T1 WHERE (T1.DATE_STAMP >= Current Date - 5 Days)

This query is connecting to a DB2/400 database and works from every desktop query tool I have but errors in DMC which is ultimately where I need this to run. The DATE_STAMP column in the statement above is setup as a DATE datatype in my synonym.

Is there a reason in particular that DMC can't seem to translate this basic query? I have seen some work arounds via DEFINES that folks have mentioned on the WebFOCUS side of the house but can't seem to find any good solutions in DMC.

Any thoughts on alternative ways to achieve this result would be appreciated.

Thanks,
Bob

This message has been edited. Last edited by: bcook278,


WebFOCUS 7.6.8
WebFOCUS Client and Server running on RedHat Linux, Developer Studio on Windows XP
All output formats
August 04, 2009, 03:45 PM
Kerry
Hi Bob,

Do you run this using SQL Pass-Thru? If so, try adding SQL DB2 to the top of the request. Here is a simple focexec to start with:

SQL DB2
SELECT T1.DATE_STAMP FROM DATE_DIM T1 WHERE (T1.DATE_STAMP >= Current Date - 5 Days);
END

TABLE FILE SQLOUT
PRINT *
END


Cheers,

Kerry


Kerry Zhan
Focal Point Moderator
Information Builders, Inc.
August 05, 2009, 03:11 PM
RivoU
Hi,

1) Is using DBMS SQL flow OK? In that case it allows you to enter dialect-specific SQL statements. So no translation will be done by adapter - SQL Pass-Thru query.

2) From the iWay DataMigrator Functions Reference you can find function called CURRENT_DATE.

For example:
WHERE T1.DATE_STAMP >= CURRENT_DATE - 5

Link to reference: http://documentation.informati...ions76/sql_date2.htm

3) Create a stored procedure which will make the date calculation.
For example:
-SET &&NDATE=AYMD(&YYMD, -5,'I8');

Then create data flow and from the SQL object, add filter like that:
T1.DATE_STAMP >= '&&NDATE'

From the same data flow, open the process flow tab. Delete the connection between Start object and Data Flow. Add there previously created stored procedure and create connections again - in order: Start object--Stored procedure--Data Flow.


Regards,
Rivo


iSM 6.0
iDM 7.6.5 - 7702
WF 7.6.4 - 7702

All output formats
August 18, 2009, 10:38 AM
Clif
If you don't want to use a DBMS SQL Flow you can create a normal Data Flow with a filter using the DAYS function like this.

SELECT T1.DATE_STAMP FROM DATE_DIM T1 WHERE ( DAYS(T1.DATE_STAMP) >= DAYS(CURRENT_DATE) - 5)

August 19, 2009, 06:29 AM
bcook278
Clif,

Your suggestion seems to actually work better then the SQL passthru. Thanks for the suggestion.

Bob


WebFOCUS 7.6.8
WebFOCUS Client and Server running on RedHat Linux, Developer Studio on Windows XP
All output formats