Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
REPLACE(
RIGHT(CONVERT(VARCHAR(9), tof.create_stamp, 6), 6), ' ', ' ') AS DateCreated,


i have above function how convert this function in month in sql server
Posted
Comments
P.Salini 5-Oct-11 8:20am    
clarify your question

SQL
SELECT datepart(month,CAST(REPLACE(RIGHT(CONVERT(VARCHAR(9), tof.create_stamp, 6), 6), ' ', ' ') as DateTime)))
 
Share this answer
 
Comments
rajjosh 5-Oct-11 8:39am    
it not worked
rajjosh 5-Oct-11 9:10am    
above code is not working tell me correct syntax
OKay, the problem is that you are doing some manipulations to the datestamp. In order for this to work you need a true date value. if tof.Create_Stamp is in fact a date then you don't need to do anything to it to retrieve the month from it.
-- try this but importantly your tof.create_stamp must be a datefield.
select DATEPART(month, tof.create_stamp)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900