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
 General SQL Server Forums
 New to SQL Server Programming
 How can I get month from a datetime type?

Author  Topic 

EltonSky
Starting Member

2 Posts

Posted - 2006-10-10 : 21:35:09
Hello guys,

I have datetime value as "mm/dd/yyyy h:m:s", my question is as title. help pls!

Cheers,

Elton

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2006-10-10 : 21:52:07
Surprisingly, you can use the Month() function.

Select Month(SomeDate)

- Jeff
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-10-10 : 22:23:47
YOu can use the DATEPART function to get the month number or DATENAME function to get the month name.
select datepart(month,Mydate), datename(month,Mydate)


CODO ERGO SUM
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-10-10 : 23:59:43
quote:
Originally posted by jsmith8858

Surprisingly, you can use the Month() function.

Select Month(SomeDate)

- Jeff





Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-11 : 10:06:12
quote:
Originally posted by EltonSky

Hello guys,

I have datetime value as "mm/dd/yyyy h:m:s", my question is as title. help pls!

Cheers,

Elton


Make sure you use DATETIME datatype

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2006-10-11 : 10:44:33
quote:
Make sure you use DATETIME datatype

Madhivanan


And do it in the front end!

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-11 : 12:07:38
>>And do it in the front end!

Yes when you want to show it in different formats

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -