Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Express Edition and Compact Edition (2005)
 mont select

Author  Topic 

nheijmink
Starting Member

8 Posts

Posted - 2008-01-09 : 14:45:54
Hi
i'am just an beginner with sql
but can sombody tell me how to select a month out of a datetime?

tnks

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2008-01-09 : 15:29:48
SELECT DatePart(month, YourDateField) FROM YourTable
Go to Top of Page

nheijmink
Starting Member

8 Posts

Posted - 2008-01-09 : 15:37:15
tnks i tought there was also something like datetime.month or month(datetime) this becouse i am using this sql in vba code.
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-01-09 : 23:26:41
There is month() function in t-sql.
Go to Top of Page

sshelper
Posting Yak Master

216 Posts

Posted - 2008-01-09 : 23:45:33
If you want to get the name of the month instead the month number, you can use the DATENAME function:

select datename(mm, getdate())

SQL Server Helper
http://www.sql-server-helper.com
Go to Top of Page
   

- Advertisement -