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.
Author |
Topic |
krushnapanda
Starting Member
18 Posts |
Posted - 2007-08-03 : 01:53:29
|
heloo dearhow to display this type of record by using SPwhen i put the number of month then the result should displaythe month name in wordslike i put 3 , then result is display MarchthanksThanks |
|
jonasalbert20
Constraint Violating Yak Guru
300 Posts |
Posted - 2007-08-03 : 02:29:17
|
declare @month as varchar(2)set @month = '3'select datename(month, @month + '/1/2007')Want Philippines to become 1st World COuntry? Go for World War 3... |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-08-03 : 03:09:02
|
orselect datename(month, dateadd(month,@month-1,0))MadhivananFailing to plan is Planning to fail |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-03 : 03:59:50
|
Or put "-1" directly into the third parameter?SELECT DATENAME(MONTH, DATEADD(MONTH, @Month, -1)) E 12°55'05.25"N 56°04'39.16" |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-08-03 : 04:39:26
|
quote: Originally posted by Peso Or put "-1" directly into the third parameter?SELECT DATENAME(MONTH, DATEADD(MONTH, @Month, -1)) E 12°55'05.25"N 56°04'39.16"
Yes if @Month is of INT datatype otherwise you need to cast it to intMadhivananFailing to plan is Planning to fail |
 |
|
krushnapanda
Starting Member
18 Posts |
Posted - 2007-08-03 : 04:49:33
|
THANKSits workquote: Originally posted by jonasalbert20 declare @month as varchar(2)set @month = '3'select datename(month, @month + '/1/2007')Want Philippines to become 1st World COuntry? Go for World War 3...
Thanks |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-03 : 05:42:19
|
quote: Originally posted by madhivanan Yes if @Month is of INT datatype otherwise you need to cast it to int
Same as your suggestion, I assume? E 12°55'05.25"N 56°04'39.16" |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-08-03 : 05:51:03
|
quote: Originally posted by Peso
quote: Originally posted by madhivanan Yes if @Month is of INT datatype otherwise you need to cast it to int
Same as your suggestion, I assume? E 12°55'05.25"N 56°04'39.16"
No. Thats the power of implicit convertion --Minedeclare @month varchar(2)set @month = '12'select datename(month, dateadd(month,@month-1,0))GoResult ------------------------------ December(1 row(s) affected) --Yoursdeclare @month varchar(2)set @month = '12'SELECT DATENAME(MONTH, DATEADD(MONTH, @Month, -1))ResultServer: Msg 8116, Level 16, State 1, Line 5Argument data type varchar is invalid for argument 2 of dateadd function. MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|