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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
JimB-GA
Helper III
Helper III

Intermittent error using R script in Power BI

I have a script that returns 2 years of closing prices for SPY.  Normally it runs without issue, but on occasion will resut in the following error: "Error in charToDate(x) :  character string is not in a standard unambiguous format"  Is there any way to trap records that cause the script to fail?  Here is the code:

 

if (!require(BatchGetSymbols)) install.packages('BatchGetSymbols')
if (!require(rio)) install.packages('rio')
library(BatchGetSymbols)
first.date = Sys.Date() - 1460
last.date = Sys.Date()
tickers <- c('SPY')
l.out <- BatchGetSymbols(tickers = tickers, 
                         first.date = first.date,
                         last.date = last.date, 
                         cache.folder = "C://users/owner/documents/r/BGS_Cache")


tickers<- as.data.frame(l.out)
library(rio)
write.table(tickers,file="Tickers.csv",sep=",")

Thanks for all advice.

 

Regards

 

Jim B

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @JimB-GA

Have you changed some date values ever since?

 

I'm not the expert of R, i searched but don't find any known issue regarding R script in Power BI like this problem.

 

As searched, there are some links you may look into.

What are the “standard unambiguous date” formats?

https://www.reddit.com/r/rstats/comments/62aco0/converting_date_format_from_dmy_time_to_dmy/

 

Best Regards

Maggie

 

I have been using BatchGetSymbols successfully (most of the time).  There is some record in the return dataset that has a bad date format in it that I can't find.  Looking to find a way to ensure all dates are in an unambiguous format.

 

Jim B

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Users online (2,230)