我如何从日期获得月份 [英] How Do I Get Month From Date

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

问题描述

我有billdate专栏我想从billdate获得一个月



假设日期是22/06/2014所以我想要的月份是06

解决方案

尝试这个.. :)



  Dim  Month  As   String  = DateTime.Now.ToString(  MM


使用datetime的month属性< br $> b $ b

http://msdn.microsoft.com/en-us/library/system.datetime.month(v = vs.110).aspx [ ^ ]


< blockquote>月份可以直接从数据库中提取日期。

如果您使用MSSQL作为数据库,则可以使用t他 DATEPART 功能来实现这一目标。



您可以像这样使用它:

  SELECT  
billdate
,DATEPART(月,billdate) AS billMonth
FROM
tblBilling





希望有所帮助。


i have billdate column i want to get month from billdate

suppose date is 22/06/2014 so i want month is 06

解决方案

TRY THIS.. :)

Dim Month As String = DateTime.Now.ToString("MM")


Use month property of datetime

http://msdn.microsoft.com/en-us/library/system.datetime.month(v=vs.110).aspx[^]


The month can be extracted from the date directly at the database.
If your using MSSQL as your database, you can use the DATEPART function to achieve this.

You can use it like this:

SELECT 
     billdate 
    ,DATEPART(month, billdate) AS billMonth
FROM
    tblBilling



Hope it helps.


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

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