1. Olan Knight
  2. PowerBuilder
  3. Friday, 28 February 2020 23:52 PM UTC

PowerBuilder v12.1, build 7055
Oracle 12C


I'm using the sqlca.of_CurrentDateTime() function to get the date and time from tthe database.

What I want is the TIME portion to include hundreths of a second:
     String ( sqlca.of_currentdatetime(), "DD-MMM-YYYY HH:MM:SS:NN )


How do I achieve this?


Thank You,

Olan

Accepted Answer
Olan Knight Accepted Answer Pending Moderation
  1. Monday, 2 March 2020 15:45 PM UTC
  2. PowerBuilder
  3. # Permalink

I found the answer with the help from these two sites:
    http://www.dba-oracle.com/t_date_format_hundredths_second.htm
    https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions037.htm


The trick is to use the TIMESTAMP dataype in Oracle

select to_char (
    CURRENT_TIMESTAMP, 'DD-MON-RR HH.MI.SSXFF PM'
    )
from dual;

returns what I need.
FYI: The "X" in the format puts a dot into the output.


select to_char (
    CURRENT_TIMESTAMP, 'DD-MON-RR_HH:MI:SS:FF'
    )
from dual;

This is the format that I will actually use.


Later -

Olan

 

Comment
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Monday, 2 March 2020 16:33 PM UTC
  2. PowerBuilder
  3. # 1

FYI:  I created this new function in CORP_N_TR:


//*********************************************************************
// Object     :  n_tr
// Function   :  of_get_extended_datetime_as_string()
//
// Ancestor   :  None
// Access     :  Public
// Arguments  :  value   long   al_format   The format of the string to return
//
// Returns    :  String         The database CURRENT_TIMESTAMP as a string
// Throws     :  None
//
// Description:  Return the current SYSDATE from the database in a
//               format that includes the Hundredths of a second.
//
//********************************************************************
// Revision History
//
// Developer   Date          Version     Description
// ---------   -----------   ---------   -------------------------------
// O Knight    02-MAR-2020   6.0.4.35    #2666065:  Initial version.
//
//********************************************************************
// < COPYRIGHT statement goes here, removed for public use>
//********************************************************************
long          ll_rc
string        ls_now



// Return FORMATs:
// 1 = US standard time format           'DD-MON-RRRR_HH:MI:SS:FF'
// 2 = US standard time format AM/PM     'DD-MON-RRRR_HH:MI:SS:FF PM'
// 3 = string search format              'RRRRMMDDHHMISSFF'
// 4 = string search format AM/PM        'RRRRMMDDHHMISSFF PM'
// 5 = military format                   'DD-MON-RRRR HH24:MI:SS:FF'
// 6 = military format, dot/hundr        'DD-MON-RRRR HH24:MI:SSXFF'
// 7 = European format                   'MON-DD-RRRR HH:MI:SS:FF'
// 7 = European format  AM/PM            'MON-DD-RRRR HH:MI:SS:FF PM'


CHOOSE CASE (al_format)
    // US Standard
    CASE 1
        SELECT to_char ( CURRENT_TIMESTAMP, 'MON-DD-RRRR HH:MI:SS:FF' )
        INTO  :ls_now
        FROM  dual;
        
    // US Standard with AM/PM
    CASE 2
        SELECT to_char ( CURRENT_TIMESTAMP, 'MON-DD-RRRR HH:MI:SS:FF PM' )
        INTO  :ls_now
        FROM  dual;        
        
    // String search
    CASE 3
        SELECT to_char ( CURRENT_TIMESTAMP, 'RRRRMMDDHHMISSFF' )
        INTO  :ls_now
        FROM  dual;        
        
    // String search with AM/PM
    CASE 4
        SELECT to_char ( CURRENT_TIMESTAMP, 'RRRRMMDDHHMISSFF PM' )
        INTO  :ls_now
        FROM  dual;            
        
    // Military
    CASE 3
        SELECT to_char ( CURRENT_TIMESTAMP, 'DD-MON-RRRR HH24:MI:SS:FF' )
        INTO  :ls_now
        FROM  dual;    
        
    // Military using dot/hundredths
    CASE 6
        SELECT to_char ( CURRENT_TIMESTAMP, 'DD-MON-RRRR HH24:MI:SSXFF' )
        INTO  :ls_now
        FROM  dual;    
        
    // European Standard
    CASE 7
        SELECT to_char ( CURRENT_TIMESTAMP, 'DD-MON-RRRR HH:MI:SS:FF' )
        INTO  :ls_now
        FROM  dual;
        
    // European Standard with AM/PM
    CASE 8
        SELECT to_char ( CURRENT_TIMESTAMP, 'DD-MON-RRRR HH:MI:SS:FF PM' )
        INTO  :ls_now
        FROM  dual;            

    CASE ELSE
        // US Standard
        SELECT to_char ( CURRENT_TIMESTAMP, 'MON-DD-RRRR HH:MI:SS:FF' )
        INTO  :ls_now
        FROM  dual;
        
END CHOOSE


RETURN ls_now

Comment
  1. John Fauss
  2. Monday, 2 March 2020 16:41 PM UTC
So you are utilizing a function that has been added as an extension to the base PFC's transaction object. I'm glad you were able to find a solution to your issue. Thanks for sharing the answer!
  1. Helpful
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Saturday, 29 February 2020 16:18 PM UTC
  2. PowerBuilder
  3. # 2

it is f, not n

   String ( sqlca.of_currentdatetime(), "DD-MMM-YYYY HH:MM:ss:ff )

https://docs.appeon.com/appeon_online_help/pb2019/pbug/ch21s04.html#d0e39143

 

 

Comment
  1. Olan Knight
  2. Monday, 2 March 2020 15:14 PM UTC
Well, I tested the "FF" this morning and the "FF" is returning "00" every time.
  1. Helpful
  1. Olan Knight
  2. Monday, 2 March 2020 15:14 PM UTC
Remember, I am in PBv12.1 running the PFC against an Oracle 12C database.
  1. Helpful
  1. mike S
  2. Monday, 2 March 2020 16:10 PM UTC
yes, it will return the value that it provided. if the pfc is using an database function without the precision needed, then you should change of_currentdatetime to use a database function that provides it
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Saturday, 29 February 2020 02:16 AM UTC
  2. PowerBuilder
  3. # 3

Hi, Olan - 

I'm not familiar with this function. Is it a locally-developed object function, or part of a framework? I've checked the PFC transaction object and it does not contain this function.

I'm unsure how anyone will be able to advise you without more information.

Does this function issue inline SQL or invoke a stored procedure? Have you tried running the same SQL from the Database Painter?

Regards, John

Comment
  1. Olan Knight
  2. Saturday, 29 February 2020 21:37 PM UTC
This is part of the PFC, as far as I know.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.