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 |
|
lici
Starting Member
11 Posts |
Posted - 2004-05-25 : 19:31:16
|
Hi everybodyI've a question: Is there a date format that shows only year and month froma a date. In the avalibles formats that appears in the t-sql help all of the formats always show at last year month and day.Sorry my english regards |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-05-25 : 19:31:57
|
| SELECT MONTH(Column1) + '/' + YEAR(Column1)FROM Table1Tara |
 |
|
|
lici
Starting Member
11 Posts |
Posted - 2004-05-25 : 19:45:32
|
| thanx tara but still i'd like to know if there is a date format. Look, i want to obtain the last day without hours and minuts and seconds from the getdate() (or any datetime data).To do this i write the next sentence:---------------------------------------declare @x datetimeset @x = '2003-12-11'select convert (datetime, convert (varchar, (year (dateadd (month, 1, @x)) * 10000) + (month (dateadd (month, 1, @x)) * 100) + 1)) - 1---------------------------------------And i jus was thinking that with a date format could write more simlpy this code.tnx |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-05-25 : 19:48:40
|
| If you don't want the time to display, then use:SELECT CONVERT(VARCHAR(10), @x, 101)101 is a style for the CONVERT function. If you look up CONVERT in BOL, you'll find a lot of different styles.Tara |
 |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-05-25 : 20:36:59
|
| There's no way to just display month and year only that I know of.MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
shounen
Starting Member
9 Posts |
Posted - 2004-05-26 : 04:18:06
|
| Hi...how about giving this a try...SELECT left(CONVERT(VARCHAR(7), getdate(), 111), 7)Hulle mal Bra,ShouneN |
 |
|
|
|
|
|
|
|