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
 date convert

Author  Topic 

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-04-18 : 05:37:34
Hi everyone. having a @date = '2007/04/01'.
How could I get the month 04? and my expected result is the actual 04.

Thanks.

-Ron-

"If you can only access one site on the Internet, make it SQLTeam!"

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-04-18 : 05:39:49
[code]Declare @date datetime

set @date = '2007/04/01'

Select Month(@date)[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-18 : 05:45:45
select @date, convert(varchar(2), @date, 103)


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-04-18 : 05:51:10
quote:
Originally posted by Peso

select @date, convert(varchar(2), @date, 103101)


Peter Larsson
Helsingborg, Sweden



Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-18 : 05:55:17
Ah! Thanks


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -