Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Translate dates & date functions to sql on database

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] Translate dates & date functions to sql on database
 Login/Join
 
Gold member
posted
Hi all,

I've spent numerous hours (days?) already on trying to figure out how to convert & work with dates.
(many thanks for the answers already provided)
but is there any documentation out there explaining
- best practices on usage of date functions & conversions (age, prev year/month, 'YYYYMM' ...)
- which functions get translated to SQL (and how)

Why my question? 2 reasons:
- I've noticed the use of a single untranslatable define negates all aggregation on database level
- I've noticed the same type of functions in WF don't always translate to similar code in Oracle

Example1: Previous month on integer field YYYYMM
- SQL: TO_CHAR(ADD_MONTHS(to_date(YEAR_MONTH||'01','YYYYMMDD'), -1), 'YYYYMM')
- WF: DATECVT(DD_TIME_FIN.YEAR_MONTH | '01', 'A6YYM', 'YYMD') - 1
--> FOC2566: CANNOT BE CONVERTED TO SQL

Example2: Age calculation on datetime fields
- SQL: (SYSDATE - SUPC_DTBTH) /365
- WF: HDIFF & DATEDIF --> FOC2566: CANNOT BE CONVERTED TO SQL
(&YYMD - HDATE(SUPC_DTBTH)) --> Agg on database! (although generated TRUNC should not be necessary)

I'm getting to something working each time, but it's taking a ridiculous amount of time, so I'm hoping (praying) this type of documentation exists as I'm bound not to be the first with this issue...

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


Prod: WebFOCUS 8.0.06 on Win2008/Tomcat7/LDAP Mode
Test: WebFOCUS 8.0.06 on Win2008/Tomcat7/LDAP Mode
 
Posts: 59 | Registered: April 23, 2012Report This Post
Virtuoso
posted Hide Post
There is a quite invaluable little booklet, called 'Almost 1001 ways to work with dates'. You may find it helpful. Last time I looked (quite a while back) it cost about 25 dollar, quite cheap for what it offers.


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
 
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007Report This Post
Expert
posted Hide Post
quote:
WF: DATECVT(DD_TIME_FIN.YEAR_MONTH | '01', 'A6YYM', 'YYMD') - 1

the format of the 1st argument isn't yym, its yymd..you've added your own '01' to it.

and &YYMD is a character string, its an &variable. If you want to work with datetime and &var in same equation, you first have to translate either the &YYMD into a datetime, or the datetime into a character string. compare like to like..

download the Using Functions manual and read the entire section on Dates and Date/Times. required reading.

if you can find a copy of the 1001 ways book Gamp refers to , super. get it.

buy a copy of WebFocus Key Sheet book. priceless!




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Expert
posted Hide Post
Consider the use of "DT", as
WHERE REPORT_DATE EQ DT(2009-02-06 12:00:00AM);
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Gold member
posted Hide Post
@GamP: Thanks for the reference, I'll take a closer look at what's inside that booklet (does 350 pages still count as a booklet?)

@Susannah: I've come to understand I shouldn't try to do several conversions within a single define, but rather create distinct defines for each conversion. (kind of an abundance in defines, but more readable I guess)
I'll go through the functions manual in more detail as opposed to using it as a reference manual.
So far I haven't found any mention yet of which functions can be translated to SQL...

@Doug: the problem with using dates in my where-clauses is its interference with the oracle aggregation underneath (if I use monthly functions on datetimes, I'll never access the monthly aggregates)

For now, I've confined myself to a couple of standard date functions which translate to SQL and have started applying them on constants/variables rather than the database fields... Working my way through it...


Prod: WebFOCUS 8.0.06 on Win2008/Tomcat7/LDAP Mode
Test: WebFOCUS 8.0.06 on Win2008/Tomcat7/LDAP Mode
 
Posts: 59 | Registered: April 23, 2012Report This Post
Member
posted Hide Post
From WF7703 on you can create define fields using SQL functions, just in case you cannot find a translatable function within WebFOCUS, and you want the calculation/aggregation to be done in SQL.
The syntax is quite simple, just type SQL. before the SQL function:
 SQL.TO_CHAR(ADD_MONTHS(to_date(YEAR_MONTH||'01','YYYYMMDD'), -1), 'YYYYMM') 
 
Posts: 8 | Location: Spain | Registered: November 05, 2010Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Translate dates & date functions to sql on database

Copyright © 1996-2020 Information Builders