每月转换此功能 [英] convert this function in month

查看:91
本文介绍了每月转换此功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

REPLACE(
RIGHT(CONVERT(VARCHAR(9), tof.create_stamp, 6), 6), ' ', ' ') AS DateCreated,



我上面的函数如何在sql server中的月份中转换此函数.



i have above function how convert this function in month in sql server

推荐答案

SELECT datepart(month,CAST(REPLACE(RIGHT(CONVERT(VARCHAR(9), tof.create_stamp, 6), 6), ' ', ' ') as DateTime)))


好吧,问题在于您对日期戳做了一些操作.为了使其正常工作,您需要一个真实的日期值.如果tof.Create_Stamp实际上是一个日期,则您无需对其进行任何操作即可从中检索月份.
-试试这个,但重要的是您的tof.create_stamp必须是日期字段.
选择DATEPART(month,tof.create_stamp)
OKay, the problem is that you are doing some manipulations to the datestamp. In order for this to work you need a true date value. if tof.Create_Stamp is in fact a date then you don''t need to do anything to it to retrieve the month from it.
-- try this but importantly your tof.create_stamp must be a datefield.
select DATEPART(month, tof.create_stamp)


这篇关于每月转换此功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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