Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
prma7799
Master III
Master III

Fetch date from excel file name

Hi All,

I have on one excel file like "Sale (Feb-2014).xlsx" .

I want to pick above Feb-2014 from excel and link to the master calender.


Need help.



Thanks,

Prashant

1 Solution

Accepted Solutions
tresesco
MVP
MVP

Use filebasename(), like:

     Load *,

               Date(Date#(TextBetween(filebasename( ), '(',')' ), 'MMM-YYYY')) as Date

     From  <>;

View solution in original post

5 Replies
tresesco
MVP
MVP

Use filebasename(), like:

     Load *,

               Date(Date#(TextBetween(filebasename( ), '(',')' ), 'MMM-YYYY')) as Date

     From  <>;

prma7799
Master III
Master III
Author

Hi Tresesco,

It is working you have any master calender script so I link them to each other.

Thanks,

Anonymous
Not applicable

Hi

You could use the function "FileName" in your script. This will give you the whole filename.

To pick the actual date part out you can use the "Mid" function, you could also use "Subfield" as well but in this case that would require more steps.

This is an example of how it might look.

Mid(FileName(),6,8) As FileNameDate,

tresesco
MVP
MVP

Anonymous
Not applicable

Trescos solution is of course much better, a bit early in the morning for me (05:00 local time)