简体   繁体   中英

MIN/MAX not working on column pushed from SQL

I am querying data from the SQL Server, and my SELECT includes CONVERT(date,[column]) .

The query runs just fine, and I pass it into a refreshable Excel workbook worksheet called 'Data'. Refreshing the workbook works just fine as well.

The issue is, on a separate 'Summary' worksheet within the same workbook, I want to run =MIN(Data!A:A) (let's just say the date column is in A:A). Thus, my goal is to retrieve the minimum/earliest date in that column. The result is always 0. I have tried formatting the Data column A:A as Date as well as the cell holding the MIN function. No matter what I do, the result seems to always be 0.

Could it be an issue with my query passing the column into Excel in an incompatible way?

cast(convert(char(11), YourDateFieldHere, 113) as datetime) will do the job. You will want to create a new connection in a new tab to see your results.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM