Focal Point
[SOLVED] UGHHHHH!!!!!! I HATE WEBFOCUS DATES

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/9017045486

November 16, 2016, 10:47 AM
Wep5622
[SOLVED] UGHHHHH!!!!!! I HATE WEBFOCUS DATES
WebFOCUS functions in general, but dates in particular, are needlessly difficult to work with. You get used to them, but that does not excuse the state they're in. The simplified functions are a big improvement, but they're incomplete at the moment.

I never understood why 'smart dates' are called smart. They're anything but smart. Calls that are simple in SQL require nested function calls or multiple statements in WF, and then you still often don't get quite what you wanted. You compromise.

And some things with dates are nearly impossible to achieve in WF. Try converting a date to a week-number and a year separately and correctly(!) for all days in weeks 1 or 53 - you'll end up with the wrong year for several days in those weeks, because there is no way to specify that you want the year that the week is part of. You'll get the year that the date is in.

In SQL, you can get those with, for example: select to_char(date, 'IW') as week, to_date(date, 'IYYY') as year from ... and you'll get the correct values.

Or try getting a date in a specific output format for which WF didn't pre-define one. There are examples of that in these forums.

Having to deal with time-zone transformations in date-time values is another fun challenge. I don't think that's even possible.

Need to handle a date or a date-time in dialog manager? Good luck with that! Especially smart dates are fun, because in many cases they will work just fine, but then you get a smart date value where a byte in the date is a 0 and your fex aborts...

There is plenty of room for improvement here. For date-times, I think the standard SQL date handling functions would be a good starting point for an API. Those are smart dates that deserve that name.


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
November 16, 2016, 03:25 PM
Waz
SQL, SQL, SQL

Frowner


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

November 17, 2016, 08:23 AM
John_Edwards
quote:
Originally posted by Francis Mariani:
It takes years of experience to be comfortable with man-handling dates. dhagen + Waz + Francis = ~ 60 years.


I'll throw 18 more on top of that. I can do dates, but they're a hassle. I always have to look something up.



November 20, 2016, 11:29 AM
David Briars
Following up to my previous post, were I was thinking that the input was an incoming date-time column from a relational table..

Here is an example of reformatting a date-time, as well as, using one of the WebFOCUS date-time functions, running against one of the MS SQL Server Adventureworks sample tables..

MFD definition of the date-time column:
FIELDNAME=RATECHANGEDATE, ALIAS=RateChangeDate, USAGE=HYYMDs, ACTUAL=HYYMDs, $  

DEFINE FILE EMPLOYEEPAYHISTORY
-* Reformat date-time to YY-Mt date-time.
 RATECHANGE_YYMT/HYYMt- = RATECHANGEDATE;
-* Get the day of the week 'part' of the date-time.  
 DAY_OF_WEEK/I2 = HPART(RATECHANGEDATE, 'DW', 'I2');
END
-*
TABLE FILE EMPLOYEEPAYHISTORY
 PRINT RATECHANGEDATE
       RATECHANGE_YYMT 
       DAY_OF_WEEK
 IF READLIMIT EQ 2
END  

  RATECHANGEDATE           RATECHANGE_YYMT  DAY_OF_WEEK                         
  --------------           ---------------  -----------                         
  2009/01/14 00:00:00.000  2009-Jan                   4
  2008/01/31 00:00:00.000  2008-Jan                   5 

November 21, 2016, 09:30 AM
jgelona
I don't know that I have ever experienced any of the issues Wep mentions. Time zones are not an issue for me because everything is in the same time zone. As for smart dates in Dialogue Manager, they are not a valid format. All variables in Dialogue Manager are strings. Also, if I have a field in one of our Oracle tables that is a true date/time field, I will generally have 2 entries in the master, something like this:

FIELD=REFER_DT,ALIAS=REFERRAL_DATETIME,USAGE=YYMD,ACTUAL=DATE,$
FIELD=REFER_DTTM,ALIAS=REFERRAL_DATETIME,USAGE=HYYMDS,ACTUAL=HYYMDS,$

Now I can use date functions on REFER_DT and date/time functions on REFER_DTTM.


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
November 21, 2016, 10:05 AM
David Briars
quote:
...Now I can use date functions on REFER_DT and date/time functions on REFER_DTTM.

+1
November 21, 2016, 11:23 AM
eric.woerle
I don't know why IBI hasn't come up with some better solution to deal with time zones... or to even just add a timezone data type to start with. I've had a NFR in for it for I think at least a year now... probably needs another 9 years before they add support for timezones into the product.


Eric Woerle
8.1.05M Gen 913- Reporting Server Unix
8.1.05 Client Unix
Oracle 11.2.0.2
November 22, 2016, 08:54 AM
jgelona
Seems to me that time zone support would depend on how date/time fields are stored internally (in the database, focus database and flat files). I don't know that I have ever seen any documentation on that. For example, I know that some date/time field like the next run date/time are stored in Zulu format in the Report Caster Repository. Knowing that, you can always adjust, for example we are Zulu time + 6 hours.

The other issue would be day light savings time and who switches and who doesn't. I know when I lived in Louisville, Kentucky switched but Indiana didn't except for the southern counties along the Ohio River across the river from Louisville did switch.


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
November 22, 2016, 09:45 AM
Squatch
Indiana uses Central Time in the northwest and southwest corners of the state, but Eastern Time everywhere else.

Imagine what it's like to work in one time zone and go home to another!


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
November 23, 2016, 11:32 AM
eric.woerle
Jgelona,

the main problem is that WF doesn't even have a data type for timezone. It all starts from there. All the major databases do though. But you can't take advantage of any of that because WF has no idea what the timezone of the data element is.


Eric Woerle
8.1.05M Gen 913- Reporting Server Unix
8.1.05 Client Unix
Oracle 11.2.0.2