Showing posts with label Function. Show all posts
Showing posts with label Function. Show all posts

Monday, December 19, 2016

SQL Server TRIM Function

I always wondering, why do I have to create my own TRIM function  in SQL Server, all this time. Even the self made TRIM function is simple to be done, but still looks silly when others have the build in function.

But don't worry, the new version of SQL Server (code name SQL Server vNext), adding the TRIM function as build in function, finally...

Beside the TRIM function, another build in functions are CONCAT_WS and TRANSLATE, based on this article.

The latest version SQL Server vNEXT is CTP 1.1 by this December. You can read the full features by clicking this link, as well as download the CTP version

Monday, September 26, 2016

SQL Server Function to Get How Long in Word

This below SQL User Defined Function script is to returns How Long the date already passed, in wording. It's usually displayed in articles to inform the reader how long the article already posted.

Wednesday, May 20, 2015

Powerbuilder Function to Check Email Address Validity

This function was made based on Visual Basic scripting. The original was created by Chad M. Kovac, and I tried to translate into Powerbuilder language and fix some minor bugs.

Thursday, April 3, 2014

Powerbuilder Function to Get Last Date in Month

This function is to get last date in particular month

Create a function named f_lastdate

Specify a date type as return value
Specify a date type parameter name dTgl, then type this script below

1:  integer iMonth, iDate  
2:  iMonth = Month(dTgl)  
3:  CHOOSE CASE iMonth  
4:       CASE 1, 3, 5, 7, 8, 10, 12  
5:            iDate = 31  
6:       CASE 4, 6, 9, 11  
7:            iDate = 30       
8:       CASE 2  
9:            IF isDate( '29/' + String(iMonth) + '/' + String(Year(dTgl))) THEN  
10:                 iDate = 29  
11:            ELSE  
12:                 iDate = 28  
13:            END IF  
14:  END CHOOSE       
15:  dTgl = Date( String(iDate) + '/' + String(iMonth) + '/' + String(Year(dTgl)))  
16:  RETURN dTgl  

To use the function, use this script

1:  Date dLastDate  
2:  dLastDate = f_lastdate(today())  

dLastDate value should be: 30 April 2014, if assume today is 3rd April 2014.

Tuesday, October 23, 2012

Wednesday, September 12, 2012

Binary to Decimal function in Powerbuilder

This script below is the user function in Powerbuilder to convert Binary number into Decimal number.

Create function name: f_bintodec, set Integer as return value, and add sBin as parameter. sBin should be String type, and choose Value as Pass By.

Friday, December 10, 2010

Set Local Computer Time with Powerbuilder

With External Function feature, we can set the Local Computer's time with Powerbuilder.

First, we need to declare the external function, called SetLocalTime from kernel32.dll

1:  FUNCTION long SetLocalTime(ref str_SYSTEMTIME lpSystemTime ) LIBRARY "kernel32.dll" alias for "SetLocalTimeA"  

To use the function, just pass a datetime variable when you call the function.

Example:
1:  DataTime dtToday  
2:    
3:  dtToday = DateTime(Today(),Now())  
4:  SetLocalTime(dtToday)  

Monday, November 1, 2010

Powerbuilder Window Function

On my last post about Powerbuilder function, I have mention that there are 2 types of function in Powerbuilder. Now, I will try to explain another function called Window Function.

The main different between Window Function and function, is Window Function must be declared in Window Object, and it should be related with windows object inside.

Thursday, October 28, 2010

Powerbuilder Function

In every modern programming languages, there is a feature call FUNCTION, as well as Powerbuilder.

FUNCTION is a collection of scripts or statment which it can be re-used. Normally, FUNCTION has a return value.

In Powerbuilder, there are 2 types of FUNCTION: Function and Window Function. The different is FUNCTION can be use anywhere in object that has capabilities to call function, but Window Function just can called in the window itself.