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 |
|
kiran
Starting Member
30 Posts |
Posted - 2004-06-30 : 17:50:04
|
| I need help in sql query in truncating seconds in datetime column that is6/30/2004 1:13:53 PM should be display as 6/30/2004 1:13 PMthanks in advance... |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-06-30 : 18:09:26
|
| Pick one: SET NOCOUNT ONDECLARE @min INT, @max INT, @date DATETIMESELECT @min = 1, @max = 131, @date = GETDATE()SELECT @dateWHILE @min <= @maxBEGIN IF @min BETWEEN 15 AND 19 OR @min = 26 OR @min BETWEEN 27 AND 99 OR @min BETWEEN 115 AND 119 OR @min BETWEEN 122 AND 125 OR @min BETWEEN 127 AND 129 BEGIN GOTO NEXT_LOOP END SELECT @min, CONVERT(VARCHAR,@date,@min)NEXT_LOOP:SELECT @min = @min + 1ENDIf you don't like any of these, get what you want with DATEPART and concatenation.MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2004-06-30 : 22:09:10
|
Another option: select convert(varchar,getdate()) |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-06-30 : 23:44:46
|
| SELECT DATEADD(Minute, DATEDIFF(Minute, 0, getdate()), 0) |
 |
|
|
|
|
|
|
|