EXCEL Power Pivot导出一天中的小时和周数

时间:2018-07-16 15:08:41

标签: excel powerpivot

在Power Pivot中构建SQL(请参见下文),无法得出一天中的小时数和周数。对于小时,我尝试了HOUR函数,但编辑器使用“ Hour not公认的内置函数”将其踢回。DatePart(“ h”,[TimeofTransaction])也失败。格式有问题,因为日期需要为字符串,我相信。周号也是如此。这是到目前为止有效的SQL:

SELECT
  Master_Accounts.Account_Type_2
 ,Transaction_Table.Transaction_Type
 ,Transaction_Table.Description
 ,Transaction_Table.Date_of_Transaction
 ,Transaction_Table.Time_of_Transaction
 ,Transaction_Table.Location_Id
 ,Transaction_Table.Extension
 ,Transaction_Table.Sku
 ,Transaction_Table.ArAmt
 ,Transaction_Table.Balls
 ,Year=DatePart("yyyy",Transaction_Table.Date_of_Transaction)
 ,MonthNo=Month(Transaction_Table.Date_of_Transaction)
 ,MonthName=Month(Transaction_Table.Date_of_Transaction)
 ,Quarter=DATEPART("q", Transaction_Table.Time_of_Transaction)
 ,DayofMonthNo=(Transaction_Table.Date_of_Transaction)
 ,Hour=HOUR(Transaction_Table.Time_of_Transaction)


FROM
  Master_Accounts
  INNER JOIN Transaction_Table
  ON Master_Accounts.Master_ID = Transaction_Table.Account_Number

谢谢

0 个答案:

没有答案