Skip to Content
avatar image
Former Member

Its a calulation -- Number of Hours to Unload

HI Gurus,

i have requirement i need to write a UDF for caliculation Time .. through graphical mapping i done..its a perfomance issue///. it is necessary to go for UDFs.

Its a calulation -- Number of Hours to Unload

((NTANZ) where QUALF=006) - ((NTANZ)where QUALF=007)

result is this Format

HHMM

Its a calulation -- Number of Hours to Unload

let me know any related links and related UDFs ...

thanks in advance

Edited by: mahesh1331 on Jun 27, 2010 11:37 AM

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Jul 02, 2010 at 01:31 PM

    Hi Mahesh i think this udf is use full your requirement

    String ret=null;

    try{

    DateFormat sdf1=new SimpleDateFormat("hhmmss");

    Date p=sdf1.parse(var1);

    Date p2=sdf1.parse(var2);

    long h=Math.abs(p.getHours()-p2.getHours());

    long m=Math.abs(p.getMinutes()-p2.getMinutes());

    long s=p2.getSeconds()-p.getSeconds();

    String hh=String.valueOf(h);

    String ss=String.valueOf(s);

    String mm=String.valueOf(m);

    if(hh.length()==1)

    hh="0"+hh;

    if(mm.length()==1)

    mm="0"+mm;

    if(ss.length()==1)

    ss="0"+ss;

    String con=hh.concat(mm).concat(ss);

    ret=con;

    }catch(ParseException pe){

    }

    return ret;

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 28, 2010 at 03:45 AM

    If you achieved your requirement using Graphical Mapping then no need to go for UDF, using UDFs not adviceble when you can achive your requirement using Graphical Mapping.

    Graphical Mapping will not give any performace issues,so you can go ahead with current mapping logic,no need to go for UDF.

    Regards,

    Raj

    Add comment
    10|10000 characters needed characters exceeded