# CTL1 to CTL2 Conversion: Function 'Today' is not declared

**URL:** <https://forum.cloverdx.com/t/ctl1-to-ctl2-conversion-function-today-is-not-declared/1144>\
**Category:** CloverDX Platform\
**Created:** [December 11, 2012, 12:00am UTC](https://forum.cloverdx.com/t/ctl1-to-ctl2-conversion-function-today-is-not-declared/1144 "2012-12-11T00:00:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wavodavo](https://avatars.discourse-cdn.com/v4/letter/w/bc79bd/32.png) [@wavodavo](https://forum.cloverdx.com/u/wavodavo)\
**Post date:** [December 11, 2012, 12:00am UTC](https://forum.cloverdx.com/t/ctl1-to-ctl2-conversion-function-today-is-not-declared/1144/1 "2012-12-11T00:00:00Z")

</div>

Hello. I’m using the Tranform Editor of IBM Initiate Workbench 9.7.0 to convert the CTL in a Reformat transformer from CTL1 to CTL2. The transformer is reading in a .txt file made by a Reformat in Phase 0 of the graph and applying a random birthdate to each record. Works fine in CTL1. The Editor is giving me an error when I convert to the randomDate code: Function ‘Today’ is not declared

I’m using the today() function. So, somewhere I don’t have my transform pointed to some global cache of functions. Any help would be appreciated.

Code that works as is:

//#TL

// Transforms input record into output record.  
function transform() {

$0.\* := $0.\*; // stage all fields ‘as is’ to output port 0  
$0.BirthDate := random\_date($0.BirthDate,today(),“yyyyMMdd”,0); // convert birthdate to a random date

}

New Code with ‘is not declared’ error:

//CTL2

// Transforms input record into output record.  
function int transform() {  
$0.BirthDate = $0.BirthDate;  
$0.Name = $0.Name;

$0.BirthDate = randomDate($0.BirthDate,today(),“yyyyMMdd”,0); // convert birthdate to a random date

return 0;  
}

The Properties for this transformer is generic (perhaps my problem)  
Basic  
Transform: //CTL2//Transforms input…  
Transform URL:  
Transform class:  
Transform source charset: ISO-8859-2 (from Dataparser DEFAULT\_CHARSET\_DECODER in default Properties)

Advanced  
Error actions:  
Error log

Visual  
Component name: MASK PII  
Description: Mask PII - Birthdate is randomized  
Location: Point(294,188)  
Size: (Dimension(0,0)

Common  
ID: REFORMAT2  
Component type: REFORMAT  
Specification: Recevies data thrugh input port, transforms them in a user specific way,…  
Phase: 1  
Enabled: enabled  
Pass through Input port:  
Pass through Output port:

Again, I need a hint where to find today() function. Thanks.

---

<div class="post-metadata">

**Author:** ![imriskal](https://avatars.discourse-cdn.com/v4/letter/i/b38774/32.png) [@imriskal](https://forum.cloverdx.com/u/imriskal)\
**Post date:** [December 12, 2012, 1:54pm UTC](https://forum.cloverdx.com/t/ctl1-to-ctl2-conversion-function-today-is-not-declared/1144/2 "2012-12-12T13:54:04Z")

</div>

Hello, wavodavo,

firstly, I would like to recommend you using CTL2 syntax for variables in CTL2 code ($0.BirthDate vs. $out.0.BirthDate) to prevent any potential name collisions. But regarding your question, I can see possible issue in randomDate argument types. random\_date in CTL1 uses dates while randomDate in CTL2 uses strings. You can find more information here:

[http://doc.cloveretl.com/documentation/UserGuide/topic/com.cloveretl.gui.docs/docs/date-functions-ctl1.html](http://doc.cloveretl.com/documentation/UserGuide/topic/com.cloveretl.gui.docs/docs/date-functions-ctl1.html)  
[http://doc.cloveretl.com/documentation/UserGuide/index.jsp?topic=/com.cloveretl.gui.docs/docs/date-functions-ctl2.html](http://doc.cloveretl.com/documentation/UserGuide/index.jsp?topic=/com.cloveretl.gui.docs/docs/date-functions-ctl2.html)

Function today() is unchanged and returns date type value so to be able to use it in CTL2, you should wrap it in date2str function. By the way, randomSeed as the fourth argument exists no more in CTL2, see the second link.

Best regards,

---

<div class="post-metadata">

**Author:** ![wavodavo](https://avatars.discourse-cdn.com/v4/letter/w/bc79bd/32.png) [@wavodavo](https://forum.cloverdx.com/u/wavodavo)\
**Post date:** [December 12, 2012, 4:06pm UTC](https://forum.cloverdx.com/t/ctl1-to-ctl2-conversion-function-today-is-not-declared/1144/3 "2012-12-12T16:06:22Z")

</div>

Thank you for your speedy reply. I’ll check the links. Consider my problem solved. If not, I’ll be ba-a-a-ack. 8)

---

<div class="post-metadata">

**Author:** ![wavodavo](https://avatars.discourse-cdn.com/v4/letter/w/bc79bd/32.png) [@wavodavo](https://forum.cloverdx.com/u/wavodavo)\
**Post date:** [January 4, 2013, 9:18pm UTC](https://forum.cloverdx.com/t/ctl1-to-ctl2-conversion-function-today-is-not-declared/1144/4 "2013-01-04T21:18:16Z")

</div>

I’m ba-a-a-ack.

In spite of yur expert advice, I still can’t complete my conversion from CTL1 to CTL2 because I’m still getting the error: Function ‘today’ is not declared

I have now made my transform function as simple as possible (see below). I declare a date variable and try to assign today’s date to it.

Am I missing an import statement to point me to global date variables?

Here is the code:

//CTL2

// Transforms input record into output record.  
function int transform() {

date Tday = today();

return 0;  
}

// Called to return a user-defined error message when an error occurs.  
// function getMessage() {}

// Called during component initialization.  
// function init() {}  
// Called after the component finishes.  
// function finished() {}

I’m using the Transform Editor of IBM Initiate Workbench 9.7.0.

The Properties for this transformer is generic (perhaps my problem)  
Basic  
Transform: //CTL2//Transforms input…  
Transform URL:  
Transform class:  
Transform source charset: ISO-8859-2 (from Dataparser DEFAULT\_CHARSET\_DECODER in default Properties)

Advanced  
Error actions:  
Error log

Visual  
Component name: MASK PII  
Description: Mask PII - Birthdate is randomized  
Location: Point(294,188)  
Size: (Dimension(0,0)

Common  
ID: REFORMAT2  
Component type: REFORMAT  
Specification: Recevies data through input port, transforms them in a user specific way,…  
Phase: 1  
Enabled: enabled  
Pass through Input port:  
Pass through Output port:

I appreciate your help. Thanks

---

<div class="post-metadata">

**Author:** ![imriskal](https://avatars.discourse-cdn.com/v4/letter/i/b38774/32.png) [@imriskal](https://forum.cloverdx.com/u/imriskal)\
**Post date:** [January 7, 2013, 8:12am UTC](https://forum.cloverdx.com/t/ctl1-to-ctl2-conversion-function-today-is-not-declared/1144/5 "2013-01-07T08:12:46Z")

</div>

Hello again,

content of your transform() function seems OK, you do not miss anything here. But try to use integer instead of int in function signature:

```auto

function integer transform() {
	date Tday = today();
	return 0;
}

```

If this does not help you, please, try to create some new test project (already in CTL2) and to type exactly the same code as above. It may be possible that some strange relicts persisted from the previous modifications of your CTL code.

Best regards,
