sql - 将日期时间转换为日期字符串 2019-05-02 12 :00:00 to 2019-05-02

标签 sql sql-server datetime ssis etl

我正在尝试在 sql 转换中的包内运行查询。尝试将日期时间转换为字符串,其中我的值为 2019-05-02 12:00:00 AM 到 2019-05-02

*
FROM <MyTable>  where datekey ='" + (DT_STR,20,1252)(@[User::NextStartTime]) + "'

我尝试了这个,但它给出的输出为 datekey = '12:00:00 AM' 但我正在寻找 '2019-05-02'

最佳答案

您可以简单地使用以下表达式:

LEFT((DT_WSTR,50)@[User::NextStartTime],10)

输出:

2019-05-10

基于Cast (SSIS Expression) official documentation :

When a string is cast to a DT_DATE, or vice versa, the locale of the transformation is used. However, the date is in the ISO format of YYYY-MM-DD, regardless of whether the locale preference uses the ISO format.

关于sql - 将日期时间转换为日期字符串 2019-05-02 12 :00:00 to 2019-05-02,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56067166/

相关文章:

php - 如果条目存在并且不使用 php 插入,请检查 mysql

mysql - 使用聚合函数过滤列以显示最大记录

mysql - 触发器和作用域标识存在问题

c# - 将当前时间添加到 DateTime?

mysql - PL SQL Procedure (Oracle) 比较 where 子句中的变量

c# - 在 SQL 中克隆带有主键的行?

SQL Table Rowcount 与 SQL Server 中的 Select Count 不同

c# - 日期时间查询错误

python - python 中的自定义类 : does a method HAVE to be called with an instance?

c# - DateTime TryParseExact 不解析类似的字符串?