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 |
|
shan1430
Yak Posting Veteran
86 Posts |
Posted - 2008-06-11 : 03:10:02
|
| Hi, I need to select date for my project.I used the following select datepart(yy,getdate())select datepart(mm,getdate())select datepart(dd,getdate()) -7and i get 200864How do I get the following result?20080604without any "." or "-"? Thanks |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-11 : 03:34:44
|
| Have a look at CONVERT() function in books online. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-06-11 : 03:38:46
|
SELECT CONVERT(CHAR(8), GETDATE() - 7, 112) E 12°55'05.25"N 56°04'39.16" |
 |
|
|
shan1430
Yak Posting Veteran
86 Posts |
Posted - 2008-06-11 : 20:56:43
|
| thanks for the reply, i used the following to get the date and also the weekselect convert (varchar,getdate()-7,112)+ convert (varchar(10),datepart(wk,getdate())-1)and i get the output as 2008060523, how do i put a white space between the date and week?i need to get 20080605 23. thanks |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-06-12 : 00:17:20
|
select convert (varchar,getdate()-7,112)+ ' ' + convert (varchar(10),datepart(wk,getdate())-1) E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|
|
|
|
|