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 |
varunm
Starting Member
25 Posts |
Posted - 2006-09-21 : 13:28:05
|
Help me In date.Its Urgent...Remove time in datetime datatype,wheni select.Please if possible psot with example.Thanks |
|
Gopi Nath Muluka
Starting Member
22 Posts |
Posted - 2006-09-21 : 13:33:37
|
see thisdeclare @dt datetimeset @dt=getdate()select @dtselect convert(varchar,@dt,101)Thanks,Gopi Nath Muluka |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
|
varunm
Starting Member
25 Posts |
Posted - 2006-09-21 : 15:14:19
|
I got that,plese look into thatselect convert(varchar,colname,101) from table |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-09-21 : 15:19:26
|
quote: Originally posted by varunm I got that,plese look into thatselect convert(varchar,colname,101) from table
Not sure what you mean, butselect convert(varchar,colname,101) from table is not a good solution because it returns a character string, not a datetime.This is a much better way to do this:select DateAdd(day,DateDiff(day,0,Datecol),0) from table CODO ERGO SUM |
|
|
Gopi Nath Muluka
Starting Member
22 Posts |
Posted - 2006-09-21 : 17:19:45
|
Solution depends on the requirements, for only display purposes I 'll go with this select convert(varchar,getdate(),101) --09/21/2006If the result is included in any other caliculations I 'll go for thisselect DateAdd(day,DateDiff(day,0,getdate()),0)--2006-09-21 00:00:00.000Thanks,Gopi Nath Muluka |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-09-21 : 17:32:15
|
If it's just for display purposes, then you should do the formatting in the presentation layer and not in T-SQL.Tara Kizer |
|
|
|
|
|
|
|