Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
 
					
				
		
 rmdnkevin
		
			rmdnkevin
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		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 -
 MindaugasBacius
		
			MindaugasBacius
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Use the FileBaseName() function:
Load *
,Right(FileBaseName(), 4) as Year
,Left(FileBaseName(),2) as Month
From
xslx
;
 
					
				
		
 ujjwalraja
		
			ujjwalraja
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		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.
 MindaugasBacius
		
			MindaugasBacius
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Use the FileBaseName() function:
Load *
,Right(FileBaseName(), 4) as Year
,Left(FileBaseName(),2) as Month
From
xslx
;
 
					
				
		
 rmdnkevin
		
			rmdnkevin
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Thanks a lot for the answer
