change format of get date function

When using this statement

select urn,GETDATE() from table1 where urn not in(select urn from table2)

the format of the date is Oct 10 2012 1:57PM. However I want it to be in this format 20121010

  • Sql Server: all object dependencies
  • Is there a solution for getting the default value of the parameters of a given stored procedure?
  • Concatenate an arbitrary length of columns per row
  • Right sql solution?
  • Multiple Columns in one table referrencing back to one table get their values
  • Dynamical ms sql query
  • Any ideas?

    2 Solutions collect form web for “change format of get date function”

    try this:

    Use CONVERT() function in sql server

    select CONVERT(varchar(8),GETDATE(),112)

    SQl fiddle demo


    select urn, CONVERT(VARCHAR(8), GETDATE(), 112) as [YYYYMMDD]
    from table1 where urn not in(select urn from table2)

    and also refer more format :
    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.