Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi.
I have a problem to create some fields such as year and month from file name.
I'm using 201801 for the file name, 2018 indicates the year and 01 means the month.
Can anyone help me how to do this ?
Thanks a lot
- Kevin -
Use the FileBaseName() function:
Load *
,Right(FileBaseName(), 4) as Year
,Left(FileBaseName(),2) as Month
From
xslx
;
Hi Kevin,
You can use the left and right function to achieve this.
For Example-
Left(201801,4) will give you 2018 i.e the Year
Right(201801,2) will give you 01 i.e the Month.
Note- To get filename in the script you can use the FileBaseName() function.
Let me know if it fulfils your requirement.
Use the FileBaseName() function:
Load *
,Right(FileBaseName(), 4) as Year
,Left(FileBaseName(),2) as Month
From
xslx
;
Thanks a lot for the answer