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 |
imranabdulaziz
Yak Posting Veteran
83 Posts |
Posted - 2010-08-12 : 23:29:03
|
Hi all,I am using sql server 2005.I have month in Parameter and Day of Date in parameter. Now i have to generate date from these parameter that is if day is 15 , month is 10 then it should be 15-10-2010.Please suggest |
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-08-13 : 00:17:40
|
It should give you idea to start with :Declare @DayParam varchar(2)Declare @MonthParam varchar(3)Set @DayParam = 15set @MonthParam = 10Select convert(datetime,@DayParam + '-' + @MonthParam + '-' + cast(year(getdate()) as varchar(4)) ,105)Regards,BohraI am here to learn from Masters and help new bees in learning. |
 |
|
Kokkula
Starting Member
41 Posts |
Posted - 2010-08-13 : 01:42:41
|
Hello,Try this....DECLARE @Month INTDECLARE @day INTSET @Month = 10 SET @Day = 21SELECT CAST(CAST(@Month AS NVARCHAR) + '/' + CAST(@Day AS NVARCHAR) + '/' + CAST(YEAR(GETDATE()) AS NVARCHAR) AS DATETIME)Hope its helpful....PavanInfosys Technologies Limited |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-08-13 : 10:30:11
|
Another methodDECLARE @Month INTDECLARE @day INTSET @Month = 10 SET @Day = 21select dateadd(year,year(getdate())-1900,dateadd(month,@month-1,@day-1))MadhivananFailing to plan is Planning to fail |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
|
|
|
|