如何将 datetime2 转换为日期时间 [英] how to cast datetime2 as datetime

查看:61
本文介绍了如何将 datetime2 转换为日期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 datetime2 转换为 datetime,以便仅使用 SQL 或 SSIS 在不同来源之间创建标准以下面的SQL查询为例:

I'm trying to convert datetime2 to datetime in order to create a standard between different sources using only SQL or SSIS Take the following SQL query as example:

SELECT CAST(offer_start_date AS timestamp)
FROM [ODS].[macaclient_offers]

我收到以下错误:'不允许从数据类型 datetime2 到时间戳的显式转换.'

I get the following error: 'Explicit conversion from data type datetime2 to timestamp is not allowed.'

此外,我确实设法使用简单的强制转换将 datetime2 转换为日期.

Furthermore, I did managed to convert datetime2 into date using a simple cast.

使用 SQL Server 2008 或 SSIS 将 datetime2 转换为 datetime 的正确方法是什么?

What is the right way to convert datetime2 to datetime using SQL Server 2008 or SSIS?

吉利

推荐答案

好的,我设法使用 SSIS 数据转换组件实现了这一点.我发现我可以使用 DT_DBTIME2 或 DT_DBTIME

OK, I managed to accomplish that using a SSIS data conversion component. I found out that I can use either DT_DBTIME2 or DT_DBTIME

感谢所有帮助过的人

这篇关于如何将 datetime2 转换为日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆