SQL Server Performance

Pivot Table with Dates Columns

Discussion in 'SQL Server 2008 General DBA Questions' started by AMOURGH, Jun 12, 2009.

  1. AMOURGH Member

    Hi Everybody, is here anyone who has generated a pivot table from a table containing a datatime column Explain: create table Sales ( City varchar(50), SaleDate DATETIME, Value DECIMAL(20,2) ) i have generated a table from data of this table that looks like: City April 1 2008 May 1 2008 Wa 2.5 6.5 the pb is that the name of dates columns are in a varchar format : April 1 2008 I want this table which has this form: City 2008/04/01 2008/05/01 Any ideas?Thanks in advance
  2. Sandy New Member

  3. Madhivanan Moderator

    [quote user="AMOURGH"]Hi Everybody, is here anyone who has generated a pivot table from a table containing a datatime column Explain: create table Sales ( City varchar(50), SaleDate DATETIME, Value DECIMAL(20,2) ) i have generated a table from data of this table that looks like: City April 1 2008 May 1 2008 Wa 2.5 6.5 the pb is that the name of dates columns are in a varchar format : April 1 2008 I want this table which has this form: City 2008/04/01 2008/05/01 Any ideas? Thanks in advance[/quote]
    Try using convert function

Share This Page