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 |
rkalyani
Starting Member
30 Posts |
Posted - 2009-07-02 : 15:56:10
|
I have to do a select with a date like this'08/01' & current year. I tried this CONVERT(datetime, '01/02' + year(GetDate()), 103) but it is comes back with an error. I am not sure how to do this. Thank you,kal30 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-07-02 : 16:15:41
|
SELECT DATEADD(YEAR, @Year - 1900, '19000801')SELECT DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()), '19000801') Microsoft SQL Server MVPN 56°04'39.26"E 12°55'05.63" |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-07-03 : 02:39:58
|
quote: Originally posted by rkalyani I have to do a select with a date like this'08/01' & current year. I tried this CONVERT(datetime, '01/02' + year(GetDate()), 103) but it is comes back with an error. I am not sure how to do this. Thank you,kal30
That should beselect CONVERT(datetime, '01/02/' + cast(year(GetDate()) as char(4)), 103)MadhivananFailing to plan is Planning to fail |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-07-03 : 02:44:20
|
Orselect CONVERT(datetime, '01/02/' + datename(year, GetDate()), 103)or SELECT DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()), '19000801') Microsoft SQL Server MVPN 56°04'39.26"E 12°55'05.63" |
|
|
rkalyani
Starting Member
30 Posts |
Posted - 2009-07-03 : 11:30:46
|
Thank you so much. It works very well for me.Thank you,kal30 |
|
|
|
|
|
|
|