cancel
Showing results for 
Search instead for 
Did you mean: 

Splitting Datetime to Date and time

Former Member
0 Kudos

Hi all,

We have a requirement where in we have to split the incoming datetime value to date and time and store it in different fields/columns in the database.

Is it possible with message mapping or do we have to use a UDF.

Provide us with a good soln.

Thanks,

Younus

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

if your input( i.e. a) is 12/12/200712:12:12, You use the UDF to split date & time..

return a.substring(10,18);---> Time

return a.substring(0,10);---> Date

Former Member
0 Kudos

hi yunus

<b>if want to go by UDF look this code</b>

This is a UDF .

java.util.Date d = new java.util.Date();

java.text.SimpleDateFormat f = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");

return f.format(d) ;

..............................................................

<b>also can use this java code in a UDF;</b>

Date now1 = new Date();

SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss.sss");

String dateString = formatter.format(now1);

return dateString;

ref: http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html

can look at this thread also

Thanks!!!

Abhishek

former_member192892
Active Contributor
0 Kudos

You can use datetrans function to get the output date and time separately from a single source node...

Former Member
0 Kudos

Hi Younus,

It is possible with standard functions only

regard

Ramesh P

Former Member
0 Kudos

hi Younus,

Suppose DATETIME is your node in source

and DATE and TIME are two different nodes in your target.

Use Node DATETIME -> DateTrans(function) -> DATE , here in DateTrans only extract DATE

Use Node DATETIME -> DateTrans(function) -> TIME, here in DateTrans only extract TIME

Regards

Ramesh P