InsightIQ Blog
1.0 Tricks of the Trade in Unica V75 – How do I dynamically add a date stamp to my list files?
Sep 28 2009
Today's discussion will yield something that you can put to use right away with respect to your Unica V75 Campaign implementation. Have you wondered how to add a dynamic date stamp to your list file name using Unica Campaign? Let's say you want to create a list pull file with the date and time in the file name. Generating a daily file with the date stamp in the file name enables you to differentiate yesterday's file from today's file. Often your mail vendor will want to be able to differentiate today's file from yesterday's file as well. So it may be a requirement when working with 3rdparty vendors to include the date and time stamp in your file name. Using the date stamp in the file name enables both you and the vendor to differentiate files across multiple dates when this file is dropped off into a folder.
So we are looking to create a list pull filename with the following syntax:
Somefilename_YYYYMMDD_TIME.txt
Here are the 4 easy steps to dynamically add a date and/or time stamp to your list pull file name using Unica Campaign.
- STEP 1. Open flowchart
- STEP 2. Create user variable
- STEP 3. Create derived field
- STEP 4. Add derived field to file name in output process box
Each of these steps has been detailed below with snapshots so that you can create your dynamic date and time stamp in your list file name using Unica Campaign.
- STEP 1. Open the flowchart that you are creating the list file from and add a select process box that selects -1 (see Figure 1). You don't need to do this step if your flowchart already has a select process box. If you already have a select process box in your flowchart then just use that one.
Figure 1. Select process box that selects -1 
- STEP 2. Generate a user variable in the flowchart with the following fields:
|
Field Name |
Enter this value |
|
Variable Name |
File_Date |
|
Data Type |
None |
|
Default Value |
YYYYMMDD |
|
Current Value |
YYYYMMDD |
Use the Tools->User Variables menu selection and open the user variable entry screen. Figure 2 shows what the user variable looks like when entered properly.
Figure 2. Generated user variable named File_Date 
- STEP 3. Create a derived field in a select process box in the flowchart which derives the current date. I created the following formula for the derived field so that the string would not impede the generation of an ASCII file name:
(STRING_CONCAT(CURRENT_DATE(YYYYMMDD),'_',SUBSTR(CURRENT_TIME(),1,2),'.',SUBSTR(CURRENT_TIME(),4,2),'.',SUBSTR(CURRENT_TIME(),7,2),'.',SUBSTR(CURRENT_TIME(),10,2))
Figure 3 shows what the derived field looks like when created in Unica. Please note that the derived field name must begin with the words UserVar. in the derived field name. As well the second part of the compound derived field name should be named exactly the same as the user variabe (i.e. File_Date). Consequently you will have a derived field with the formula above and the name 'UserVar.File_Date'.
Figure 3. Derived Field named 'UserVar.File_Date' 
- STEP 4. In the mail list process box configure the file name to include the user variable. Since the derived field is named "UserVar.File_Date" you need to add the derived field name to the file name with the '<>' brackets on either end of the field name. Figure 4 shows what this looks like in the mail list process box.
Figure 4. Dynamic Date and Time Stamp in Output file name 
Now all that is left is to save an run your flowchart. Once you have run the flowchart successfully you should be able to review the output file in the output folder. And you should now be the proud owner of a dynamically named file with the name:
"file_with_datestamp_20090922_10.25.46.AM.dat"
Figure 5 shows the dynamically named file in the output folder. Your dynamically named file should have both the date and time stamp if you used the formula I provided above.
Figure 5. File with dynamic date and time stamp in its name in the output folder 
Now that I have given you a trick of the trade you can go ahead and do me a favor. Why don't you play a trick on someone for me? Next time you have someone assisting you with your Unica Campaign application efforts go ahead and test them. Ask them how one can add a dynamic date stamp to a list pull file using Unica Campaign. Or ask them where to find these steps in the Unica User Guide. Let me know how it goes by responding to my blog or dropping me a line ;)
Check back soon for my next blog on "tricks of the trade".
Leave Your Comment Comments
May 18 2010
Nice tip - I've played with something similar myself but rather than create a derived field I make the default value of my User Variable "date_format(current_date(),DELIM_M_D_Y,YYYYMMDD)”
Strange as it sounds this has been working, but as soon as I started playing with get (getting clever with current_date()+2) it stopped working. Now instead of evaluating the formula the whole thing is output in the file name. Very strange and very frustrating!
Jun 3 2010
I see what you mean. But, isnt that exactly the point of using derived fields ?
Nov 10 2010
Excellent tip, which worked perfectly. Thank you for sharing.
Apr 20 2011
hi it gives me error while i am giving file name timestamp_<UserVar.file_date>.txt it gives me error file contains invalid path.please help



From Razvan George Diaconu: Very good article. Useful information. Thanks
From Bill Connolly: Hi Naras, Like you said, the movement yesterday speaks very highly of our country's…
From Naras Eechambadi: Bill, I agree with you. It looks like Congress took a bunch of campaign money from the…