Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
divya_anand
Creator III
Creator III

Assign Excel file name to a variable

Hi,

I have excel files with the name that include the date. I would like to extract this date in the file name and assign it to a variable.

Any thoughts how I could achieve this?

I use the below expression to extract the date

Date(Date#(SubField(FileBaseName(),'-',1),'YYYYMMDD'),'DD-MMM-YYYY')

Thank you.

5 Replies
Anonymous
Not applicable

Can you provide the sample Filename??

Anonymous
Not applicable

Hi divya,

Your expression looks fine. To assign a value to a variable you can use Peek() after the load statement.

Anil_Babu_Samineni

Try to split expression and check then date and date#

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable

you cant assign variable properly in a load statement.

can you do the assignment of variable and load statement separately?

Ralf_Heukäufer
Partner - Creator III
Partner - Creator III

Hello,

is it one file or more?

If it is one File and the data is in your table you can try something like this:

Date(Date#(SubField(FileBaseName(),'-',1),'YYYYMMDD'),'DD-MMM-YYYY')  as Filename

Temp_Filename:

Load Max(Filename) as tempMax Resident NameofyourTable;

let v_Filename = FieldValue ('tempMax',1);

Drop Table Temp_Filename;

In the case you have more than one filenames you must work with a for each loop and a variable instead of the filename.