如何从日期时间值中查找月份数 [英] how to find month number from datetime values

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

问题描述

大家好!

我有一个存储日期时间类型值

Hi all!!

i have a feild which stores datetime type values

2011-11-30 00:00:00.000


的领域 我想从中检索月份号.
我需要其他一些sql-query的月份号.我尝试使用子字符串,但它给了我错误


I want to retrieve month number from this .
I need month number for some other sql-query . i tried using substring but it gives me error

Argument data type datetime is invalid for argument 1 of substring function.


请告诉我如何获取它!!!!


Please tell me how to retrieve it!!!!

推荐答案

DATEPART(mm,date)函数可用于此目的,如此处所述
http://www.w3schools.com/sql/func_datepart.asp [
The DATEPART(mm,date) function can be used for this purpose as explained here
http://www.w3schools.com/sql/func_datepart.asp[^]




您是否要从给定日期获取值"11"?
尝试一下:

选择MONTH(''2011-11-30 00:00:00.000'')

谢谢.
Hi,

Are you trying to get the value ''11'' from the given date?
Just try this:

select MONTH(''2011-11-30 00:00:00.000'')

Thank You.


这篇关于如何从日期时间值中查找月份数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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