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

UiPath中DateTime.ParseExact无法使用问题求助

UiPath DateTime.ParseExact 红波浪线报错解决办法
  • 核心问题:你代码里的格式字符串用了中文双引号(“dd.MM.yyyy”),UiPath的VB语法要求必须用英文双引号("dd.MM.yyyy"),这就是yyyy下出现红波浪线的直接原因。
  • 修正后的代码:
    DateTime.ParseExact(CurrentRow.Item("Date").ToString.Trim(), "dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture)
    
  • 额外排查步骤:
    • 先通过LogMessage活动输出CurrentRow.Item("Date").ToString.Trim()的内容,确认没有隐藏的空格、特殊字符,确保确实是dd.MM.yyyy格式的字符串
    • 如果担心个别行数据异常导致报错,建议改用TryParseExact做容错处理,避免流程中断:
      Dim targetDate As DateTime
      If DateTime.TryParseExact(CurrentRow.Item("Date").ToString.Trim(), "dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture, Globalization.DateTimeStyles.None, targetDate) Then
          YourDateTimeVariable = targetDate
      Else
          LogMessage($"解析日期失败:{CurrentRow.Item("Date").ToString}", LogLevel.Warning)
      End If
      
    • 用ItemArray的话,要确认索引值对应Date列的位置(索引从0开始),比如Date是第2列的话,代码是CurrentRow.ItemArray(1).ToString.Trim()

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.09 04:14:51