You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:修改SQL查询以获取计算机中软件的安装日期

Alright, let's tackle this since it looks like you're querying a Configuration Manager (SCCM) database based on the tables/functions you're referencing!

To pull in the installation date for each software product, you'll need to use the InstallDate0 field—this is the standard field in SCCM's inventory views that stores software installation dates. Most often, this field is stored as a yyyymmdd formatted string, so we'll add a conversion to make it a readable date type too.

Here's your modified query (note I fixed a likely typo in the domain/workgroup field name):

SELECT DISTINCT 
    SYS.Netbios_Name0, 
    SYS.Resource_Domain_OR_Workgr0,  -- Corrected typo from Rsqlesource_Domain_OR_Workgr0
    SP.CompanyName, 
    SP.ProductName, 
    SP.ProductVersion,
    -- Convert yyyymmdd string to a proper date format, handle nulls/invalid values
    CASE 
        WHEN SP.InstallDate0 IS NOT NULL AND LEN(SP.InstallDate0) = 8 THEN CONVERT(DATE, SP.InstallDate0, 112)
        ELSE NULL 
    END AS InstallDate
FROM 
    fn_rbac_Add_Remove_Programs(@UserSIDs) SP  -- Adjust the fn_ function if you're using 64-bit programs (fn_rbac_Add_Remove_Programs64)
JOIN 
    v_R_System SYS ON SP.ResourceID = SYS.ResourceID

A few key notes:

  • If you're targeting 64-bit installed programs specifically, swap fn_rbac_Add_Remove_Programs with fn_rbac_Add_Remove_Programs64—the InstallDate0 field exists in both views.
  • The CASE statement ensures we only convert valid yyyymmdd strings to dates, avoiding errors from null or malformed values in the inventory data.
  • If you don't need the date conversion (e.g., you're okay with the raw yyyymmdd string), you can simplify it to just SP.InstallDate0 AS InstallDate.

内容的提问来源于stack exchange,提问作者Isma Isma

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 07:55:06