# File url with timestamp for delimited\_data\_writer

**URL:** <https://forum.cloverdx.com/t/file-url-with-timestamp-for-delimited-data-writer/566>\
**Category:** CloverDX Platform\
**Created:** [August 7, 2009, 12:00am UTC](https://forum.cloverdx.com/t/file-url-with-timestamp-for-delimited-data-writer/566 "2009-08-07T00:00:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tava.amitava](https://avatars.discourse-cdn.com/v4/letter/t/c6cbf5/32.png) [@tava.amitava](https://forum.cloverdx.com/u/tava.amitava)\
**Post date:** [August 7, 2009, 12:00am UTC](https://forum.cloverdx.com/t/file-url-with-timestamp-for-delimited-data-writer/566/1 "2009-08-07T00:00:00Z")

</div>

Hi,  
I have created a graph to create a delimited text file by reading data from database. Whenever I run the graph it writes the result in the same file. I want to give the file name with time stamp so that every time a separate file generate.

```auto
<Phase number="0">
	<Node dbConnection="conn" id="INPUT0" sqlQuery="select 'HEADER','SAO','SAO AIP',rtrim(CHAR(year(current timestamp)))||RIGHT('0'||RTRIM(CHAR(month(current timestamp))),2)||RIGHT('0'||rtrim(CHAR(day(current timestamp))),2)||RIGHT('0'||rtrim(CHAR(HOUR (current timestamp))),2)||RIGHT('0'||rtrim(CHAR(MINUTE (current timestamp))),2),'06','00' from sysibm.sysdummy1" type="DB_INPUT_TABLE"/>
	<Node append="false" fileURL="../files/download/SAO_FILE_SMSMESSAGE.dat" id="OUTPUT0" type="DELIMITED_DATA_WRITER"/>				 
	<Edge id="INEDGE0" fromNode="INPUT0:0" toNode="OUTPUT0:0" metadata="headerMeta"/>
</Phase>

```

Thanks for your help.  
Regards,  
Amit

---

<div class="post-metadata">

**Author:** ![avackova](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@avackova](https://forum.cloverdx.com/u/avackova)\
**Post date:** [August 7, 2009, 9:13am UTC](https://forum.cloverdx.com/t/file-url-with-timestamp-for-delimited-data-writer/566/2 "2009-08-07T09:13:57Z")

</div>

Hello Amit,  
you can use auto filling field in your reader with _row\_timestamp_ or _reader\_timestamp_ function (see [auto\_filling](http://wiki.cloveretl.org/doku.php?id=graph%5Felements:metadata&s=auto%20filling#auto%5Ffilling)), and then _partitionKey_ in your writer (see [Data Writer](http://wiki.cloveretl.org/doku.php?id=components:writers#datawriter)).  
See following graph as an example:

```auto
<?xml version="1.0" encoding="UTF-8"?>
<Graph name="Testing DB Unload" >
<Global>
<Metadata id="Metadata0" >
<Record fieldDelimiter=";" name="employee" recordDelimiter="\n" recordSize="-1" type="delimited">
<Field name="employee_id" nullable="true" shift="0" type="integer"/>
<Field name="full_name" nullable="true" shift="0" type="string"/>
<Field auto_filling="reader_timestamp" format="HHmmss" name="time" type="date"/>
</Record>
</Metadata>
<Metadata id="Metadata1" >
<Record fieldDelimiter=";" name="employee" recordDelimiter="\n" recordSize="-1" type="delimited">
<Field name="employee_id" nullable="true" shift="0" type="integer"/>
<Field name="full_name" nullable="true" shift="0" type="string"/>
<Field name="time" type="string"/>
</Record>
</Metadata>
<Connection dbConfig="${CONN_DIR}/postgre.cfg" id="Connection0" type="JDBC"/>
<Property fileURL="workspace.prm" id="GraphParameter0"/>
</Global>
<Phase number="1">
<Node dbConnection="Connection0" id="INPUT" sqlQuery="select * from employee" type="DB_INPUT_TABLE"/>
<Node append="false" excludeFields="time" fileURL="${DATAOUT_DIR}/employees." id="OUTPUT" partitionFileTag="keyNameFileTag" partitionKey="time" type="DATA_WRITER"/>
<Node id="REFORMAT0" type="REFORMAT">
<attr name="transform"><![CDATA[//#TL

// Transforms input record into output record.
function transform() {
	$0.employee_id := $0.employee_id;
	$0.full_name := $0.full_name;
	$0.time := date2str($0.time, "HH-mm-ss") + ".dat";
}

]]></attr>
</Node>
<Edge debugMode="true" fromNode="INPUT:0" id="INEDGE" inPort="Port 0 (in)" metadata="Metadata0" outPort="Port 0 (out)" toNode="REFORMAT0:0"/>
<Edge fromNode="REFORMAT0:0" inPort="Port 0 (in)" metadata="Metadata1" outPort="Port 0 (out)" toNode="OUTPUT:0"/>
</Phase>
</Graph>

```

---

<div class="post-metadata">

**Author:** ![mzatopek](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@mzatopek](https://forum.cloverdx.com/u/mzatopek)\
**Post date:** [September 14, 2009, 11:30am UTC](https://forum.cloverdx.com/t/file-url-with-timestamp-for-delimited-data-writer/566/3 "2009-09-14T11:30:32Z")

</div>

Probably the most easiest way how to reach your goal is to exploit the new functionality, which is available since 2.8 version. Consider the CTL statement in an arbitrary component attribute:

fileURL=“${DATAOUT\_DIR}/result`date2str(today(), “ddMMyyyy”)`.txt”

This is probably exactly what you need 😉
