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 |
|
edusqluser
Starting Member
15 Posts |
Posted - 2010-07-11 : 19:42:01
|
| Anyone have the data style format for mm/yy?THX, EDUSQLUSER |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
edusqluser
Starting Member
15 Posts |
Posted - 2010-07-11 : 22:21:50
|
| This is my sample:DECLARE @datBegin AS DATETIMEDECLARE @datEnd AS DATETIMESET @datBegin = '@@START_DATE@'SET @datEnd = '@@END_DATE@'REPLACE (CONVERT (VARCHAR(10), '@@END_DATE@',103 ), '/', ' ')Any suggestions to produce the mm yy?THX, EDUSQLUSER |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-07-11 : 22:56:30
|
[code]select right(convert(varchar(10), getdate(), 3), 5)[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2010-07-12 : 04:05:52
|
| select substring(convert(varchar(10), getdate(), 3),4, 6)Jack Vamvas--------------------http://www.sqlserver-dba.com |
 |
|
|
edusqluser
Starting Member
15 Posts |
Posted - 2010-07-12 : 12:45:12
|
| Thanks. But I need to replace the "/". How do you do a Replace and a Right together so that the result is mm yy and not mm/yy?THX, EDUSQLUSER |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-07-16 : 11:48:07
|
| If it is for formatting purpose, do it there in your front end applicationIf it is for finding all data for those months and year, usewhere date_col>=dateadd(month,datediff(month,0,@datBegin),0) anddate_col<dateadd(month,datediff(month,0,@datEnd)+1,0) MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|