Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

retrieving system date in powerbuilder

Status
Not open for further replies.

peglin

IS-IT--Management
Jul 12, 2002
14
US
hi.
how can the system date(current date) be retrieved?

thanks.
 
Hi,

There are a couple of points to consider in your situation:

1. If you just want the local machine date, you could use the Today() function embeding it within the String() function for the right format. This would be fine for most reports.

2. If you are inserting data into a database, you would do well to get the Server-Date from your database and then populate the value. You could write a Global function to do this so it could be re-used. Following is the code for Oracle database:

///////////////////////////////////////////////////////////////
FUNCTION integer f_Today( REF dateTime ldt_Today )
///////////////////////////////////////////////////////////////
// The System-date value is passed by reference here
///////////////////////////////////////////////////////////////
uLong lul_Handle ;
////////////////////
//
SetNull( ldt_Today ) ; // Init!
//
// Check for Database connection
lul_Handle = SQLCA.DBHandle() ;
//
IF IsNull( lul_Handle ) OR lul_Handle <= 0 THEN
RETURN -1 ; // Failure
END IF ;
//
SELECT SysDate
INTO :ldt_Today
FROM DUAL
USING SQLCA ;
//
IF SQLCA.SQLCode <> 0 THEN
SetNull( ldt_Today ) ; // Init!
END IF ;
//
RETURN 1 ; // Success

///////////////////////////////////////////////////////////////


Regards,

--
PowerObject!
---------------------------------------------------
 
Hi,

I missed a line of code (RETURN -1) at the end inadvertently. Here is the corrected script for the function:

///////////////////////////////////////////////////////////////
FUNCTION integer f_Today( REF dateTime ldt_Today )
///////////////////////////////////////////////////////////////
// The System-date value is passed by reference here
///////////////////////////////////////////////////////////////
uLong lul_Handle ;
///////////////////////
//
SetNull( ldt_Today ) ; // Init!
//
// Check for Database connection
lul_Handle = SQLCA.DBHandle() ;
//
IF IsNull( lul_Handle ) OR lul_Handle <= 0 THEN
RETURN -1 ; // Failure
END IF ;
//
SELECT SysDate
INTO :ldt_Today
FROM DUAL
USING SQLCA ;
//
IF SQLCA.SQLCode <> 0 THEN
SetNull( ldt_Today ) ; // Init!
RETURN -1 ;
END IF ;
//
RETURN 1 ; // Success

///////////////////////////////////////////////////////////////


Regards,

--
PowerObject!
---------------------------------------------------


--
PowerObject!
 
thanks for your help. I didn't get to check the response for the past few days.

I wanted to know if you can guide me on if I wanted to set the date from a GUI, how would I do that? For example, I have made a GUI with a GroupBox control named &quot;Select a time period&quot; In the groupbox there are RadioButtons This week, last week , and specify a date where This week represents the last day of the current week. Last week represents the last day of last week and Specify Date allows the person to specify the date. If I speciy the date, I have to go to a table and find the specified date from the table.However, this table has the values in Julian Date format.

I hope what I am asking is clear. I'd appreciate your help.

Thanks.
 
Do you know how to do the conversions in Powerbuilder using Sybase Central as the database? If not do you know of any other forums for powerbuilder and sybase central?

thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top