• Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » How to format a Date to use as input in a tMAP

#1 2007-03-21 16:07:52

hbap
Member
Registered: 2007-03-20
Posts: 27

How to format a Date to use as input in a tMAP

Tags: [date format, tmap]

On the Help menu I found this piece of code, that allow me to format a datetime.

use POSIX qw(strftime);
$now_datetime = strftime "%Y-%m-%d %H:%M:%S", gmtime;

How can I put this to be an value of one output column in the tMap? May I use a variable to do this, or I can write an expression?

I already put this in the selected column (see image in attach) but when I run it gives me this error:

use POSIX qw(strftime);
strftime "%Y-%m-%d %H:%M:%S", gmtime;

or

use POSIX qw(strftime);
$now_datetime = strftime "%Y-%m-%d %H:%M:%S", gmtime;

(Expecting that the last line executed is what  will be inserted in the output column )

String found where operator expected at
D:\JAVA\TOS-2.0.0M2\TOS-Win32-r2461-V2.0.0M2\workspace\.Perl\TALEND_2.job_Teste_exp1.pl line 3067, near
              "strftime "%Y-%m-%d %H:%M:%S""
          (Do you need to predeclare strftime?)


To resume, all I want is format a date an put that in a output collumn in tMAP component.

Thanks in advance wink

Offline

#2 2007-03-21 16:10:06

hbap
Member
Registered: 2007-03-20
Posts: 27

Re: How to format a Date to use as input in a tMAP

Here is the image ... tongue


Uploaded Images

Offline

#3 2007-03-21 17:07:03

plegall
Member
Registered: 2006-09-19
Posts: 1586
Website

Re: How to format a Date to use as input in a tMAP

Create a routine file with the following content:

Code:

use Exporter;

use vars qw(@EXPORT @ISA);

@ISA = qw(Exporter);
@EXPORT = qw(
    getNow
);

sub getNow {
    use POSIX qw(strftime);
    return strftime "%Y-%m-%d %H:%M:%S", gmtime;
}

1;

Use this function in your tMap as described in the screenshot.

Code:

Starting job topic397 at 17:03 21/03/2007.
1|2007-03-21 16:03:28
2|2007-03-21 16:03:28
3|2007-03-21 16:03:28
4|2007-03-21 16:03:28
5|2007-03-21 16:03:28
Job topic397 ended at 17:03 21/03/2007. [exit code=0]

Uploaded Images

Offline

  • Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » How to format a Date to use as input in a tMAP

Board footer

Powered by FluxBB