Re: Date formatting - Really newbie question



I don't quite see how that works (20 is too long, and the is only one parenthesis). To
convert a datetime value to the same date at midnight, this is one solution:

dateadd(day,datediff(day,0,[Date]),0)

-- Steve Kass
-- Drew University
-- http://www.stevekass.com

Chuck G. wrote:

Solved this. If anyone else is as inexperienced as I am and has this problem, you can use the following method to change the output of the datetime in this method.

Select CONVERT(varchar(20), [Date] as DT

will change this
1/30/2007 10:00:00
to this
1/30/2007

"Chuck G." wrote:



I have a unbelievably stupid problem that I can't figure out. My table is imported from access and contains a column with data type datetime. I want to be able to sum the data (which is a door counter for our store) to show me all of the traffic for the day, then display the date as 1/1/2007 instead of 1/1/2007 12:00:00 PM. I have tried this... (which is how I interpret the BOL help on this topic)...

convert(smalldatetime, [Date], 101)

No matter what I put in the style portion of the select statement it has no impact on my output format. I suppose I could convert this to a varchar and trim the results but that seems to be overkill (in addition to beiing a poor solution).




.



Relevant Pages

  • datetime iso8601 string input
    ... support any kind of conversion from string. ... The number of bottomless pits in any datetime ... output format for datetime? ...
    (comp.lang.python)
  • Re: formatting date field
    ... If the column type is DATETIME then you won't even need to cast it as ... Look more into syntax of CONVERT and you ... can find out more about styles of output format. ... HTH ...
    (microsoft.public.sqlserver)
  • Re: Variable substitution to replace switch
    ... function addtime ... // How to add time to $datetime (data type datetime) and return it as ... but I would like to replace the switch statement with one ...
    (comp.lang.php)
  • Variable substitution to replace switch
    ... // How to add time to $datetime (data type datetime) and return it as ... $timestamp = strtotime; ... but I would like to replace the switch statement with one ...
    (comp.lang.php)
  • Re: Data Type conversion from int to datetime
    ... This conversion assumes the integer contains the number of days since ... you'll need to first convert it to character and then to datetime. ... CAST queries using various intermediate datatypes to get the conversion, ... Arithmetic overflow error converting expression to data type datetime. ...
    (microsoft.public.sqlserver.programming)