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     [SOLVED] Subtract 48 hrs from current Date & Time

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Subtract 48 hrs from current Date & Time
 Login/Join
 
Member
posted
I'm trying to subtract 48 hrs from the current date and time and I would like to do this without having to calculate date and time separately. This is what I have so far but All I get for the &prev_48 is the year and a strange character. Any suggestions?

-SET &DATE_TIME = HCNVRT(HGETC(8, 'HYYMDS'),'(HYYMDS)',20, 'A20');

-SET &PREV_48 = HADD(&DATE_TIME, 'HOUR',-48, 8, 'HYYMDS');

This is what the output looks like

2014/02/14 12:22:11
2014ú/

This message has been edited. Last edited by: <Kathryn Henning>,


WebFOCUS 7.6
Windows, All Outputs
 
Posts: 13 | Registered: August 22, 2013Report This Post
Virtuoso
posted Hide Post
Try this:
-SET &PREV_48 = HCNVRT(HADD(HGETC(8, 'HYYMDS'), 'HOUR', -48, 8, 'HYYMDS'), '(HYYMDS)',20,'A20');
-TYPE &PREV_48



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Report This Post
Virtuoso
posted Hide Post
This may make it a bit clearer:

-SET &DATE_TIME_HYYMDS = HGETC(8, 'HYYMDS');
-SET &PREV_48_HYYMDS   = HADD(HGETC(8, 'HYYMDS'), 'HOUR', -48, 8, 'HYYMDS');
-SET &DATE_TIME        = HCNVRT(&DATE_TIME_HYYMDS, '(HYYMDS)', 20, 'A20');
-SET &PREV_48          = HCNVRT(&PREV_48_HYYMDS, '(HYYMDS)',20,'A20');

-TYPE &DATE_TIME
-TYPE &PREV_48



HADD() requires a "date-time" parameter to operate upon, not the string representation of a date and time (A20). That's explains the strange symbols you were getting in WF 7.6.

WebFOCUS 7.7.x has stricter data type validations and fails with an error making it easier to debug:
(FOC36355)  INVALID TYPE OF ARGUMENT #1 FOR USER FUNCTION HADD



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Report This Post
Member
posted Hide Post
Thank you, both options worked and thanks for the clarification on date-time parameter vs string of date and time.


WebFOCUS 7.6
Windows, All Outputs
 
Posts: 13 | Registered: August 22, 2013Report This Post
Member
posted Hide Post
Running into a different issue now and believe it is related to the whole sting vs date-time format.

I'm trying to define a field based on what we set above but I'm getting syntax error (FOC224) SYNTAX ERROR: 18:26:45


DEFINE FILE PROBSUMMARYM1
prev48/HYYMDS=&PREV_48;

I tried the following

-SET &TEST = HINPUT(20, '&PREV_48', 8, 'HYYMDS');

I'm able to define a field using &TEST but when I check to see the value by -TYPE &TEST it doesn't diplay anything.

What am I not understanding between alphanumeric sting vs date format?


WebFOCUS 7.6
Windows, All Outputs
 
Posts: 13 | Registered: August 22, 2013Report This Post
Virtuoso
posted Hide Post
quote:
Originally posted by Tonyperkis:
Running into a different issue now and believe it is related to the whole sting vs date-time format.

I'm trying to define a field based on what we set above but I'm getting syntax error (FOC224) SYNTAX ERROR: 18:26:45


It's a string literal, it requires quotes. The best way in this case is to use &PREV_48.QUOTEDSTRING.

Don't use .QUOTEDSTRING on parameters that can be FOC_NONE though, it will translate the value in the string 'FOC_NONE' causing WF to not ignore the line that parameter is on.

quote:
DEFINE FILE PROBSUMMARYM1
prev48/HYYMDS=&PREV_48;

I tried the following

-SET &TEST = HINPUT(20, '&PREV_48', 8, 'HYYMDS');

I'm able to define a field using &TEST but when I check to see the value by -TYPE &TEST it doesn't diplay anything.

What am I not understanding between alphanumeric sting vs date format?


You're trying to assign a DATETIME value to a dialog manager variable. DM doesn't understand DATETIMEs. FOCUS does, however, so this should work:
DEFINE FILE PROBSUMMARYM1
  TEST  = HINPUT(20, '&PREV_48', 8, 'HYYMDS');
END


Your other mistake in above code is putting a DM variable between quotes in DM code. If you do that, the variable will not be evaluated, so there's a literal '&PREV_48' in your statement and that's not a valid value for a DATETIME. However, in FOCUS code that does work (and often the opposite won't).

You'll need to be more aware of when you're using DM and when you're using FOCUS, as the two are different languages. DM is more like a pre-processor language, while FOCUS does the databasy stuff.


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 :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 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     [SOLVED] Subtract 48 hrs from current Date & Time

Copyright © 1996-2020 Information Builders