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 |
|
tribune
Posting Yak Master
105 Posts |
Posted - 2004-04-28 : 18:27:50
|
| How do I get the date in the format of yyyy-mm-dd? I've tried convert and couldnt get what I wanted, instead I had to break down the operation into about a dozen parts:select Right('0' + Cast(DatePart(yy, getdate()) as varchar(4)), 4) + '-' + Right('0' + Cast(DatePart(m, getdate()) as varchar(4)), 2) + '-' + Right('0' + Cast(DatePart(d, getdate()) as varchar(4)), 2) |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-04-28 : 18:40:58
|
| SELECT SUBSTRING(CONVERT(VARCHAR(50), GETDATE(), 120), 1, 10)Tara |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-04-29 : 05:02:45
|
| or convert(varchar(10),getdate(),120)be careful though - yyyy-mm-dd isn't always converted implicitely. In sql server for instance it will depend on the settings an may be interpretted as yyyy-dd-mm.yyyymmdd is always unambiguous.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
tribune
Posting Yak Master
105 Posts |
Posted - 2004-04-30 : 11:18:28
|
| thanks |
 |
|
|
|
|
|