p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   SQL Language (http://p2p.wrox.com/forumdisplay.php?f=100)
-   -   get current month (http://p2p.wrox.com/showthread.php?t=38921)

cathiec February 23rd, 2006 08:43 AM

get current month
 
hi all,

i need to get the current month in a query that i am writing - based on the sysdate. i was trying something like month(sysdate) but its not working.

would appreciate any help!
thanks


SqlMenace February 23rd, 2006 09:09 AM

A couple of ways

select month(getdate()) --2
select datepart(m,getdate()) --2
select datename(m,getdate()) --February
select month(CURRENT_TIMESTAMP) --2



“I sense many useless updates in you... Useless updates lead to fragmentation... Fragmentation leads to downtime...Downtime leads to suffering..Fragmentation is the path to the darkside.. DBCC INDEXDEFRAG and DBCC DBREINDEX are the force...May the force be with you" -- http://sqlservercode.blogspot.com/

cathiec February 23rd, 2006 09:58 AM

thanks - the first one worked perfectly!



All times are GMT -4. The time now is 04:05 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.