none
Obter somente a data de data e hora RRS feed

Respostas

  • Tente desta forma: 

    Retorna somente a data

    SELECT CONVERT(CHAR(10),data,111) FROM tabela

    Retorna somente a Hora

    SELECT CONVERT(CHAR(10),data,114) FROM tabela

    quarta-feira, 23 de abril de 2014 14:00
  • Ou tambem para retorna somente a Hora

    SELECT CONVERT(CHAR(10),data,108) FROM tabela

    PS: Mais informações sobre o CONVERT

     http://technet.microsoft.com/pt-br/library/ms187928.aspx

    • Marcado como Resposta Diogo Ichiyama quarta-feira, 23 de abril de 2014 14:11
    quarta-feira, 23 de abril de 2014 14:09
  • Só pra registrar outras dicas

    SELECT CONVERT(CHAR(20),getdate(),1) AS 'MM/DD/YY' SELECT CONVERT(CHAR(20),getdate(),2) AS 'YY.MM.DD' SELECT CONVERT(CHAR(20),getdate(),3) AS 'DD/MM/YY' SELECT CONVERT(CHAR(20),getdate(),4) AS 'DD.MM.YY' SELECT CONVERT(CHAR(20),getdate(),5) AS 'DD-MM-YY' SELECT CONVERT(CHAR(20),getdate(),6) AS 'DD mmm YY' SELECT CONVERT(CHAR(20),getdate(),7) AS 'mmm DD, YY' SELECT CONVERT(CHAR(20),getdate(),8) AS 'HH:MM:SS' SELECT CONVERT(CHAR(20),getdate(),9) AS 'mmm DD YYYY HH:MM:SS' SELECT CONVERT(CHAR(20),getdate(),10) AS 'MM-DD-YY' SELECT CONVERT(CHAR(20),getdate(),11) AS 'YY/07/31' SELECT CONVERT(CHAR(20),getdate(),12) AS 'YYMMDD' SELECT CONVERT(CHAR(20),getdate(),13) AS 'DD mmm YYYY HH:MM:SS' SELECT CONVERT(CHAR(20),getdate(),14) AS 'HH:MM:SS:000'

    SELECT CONVERT(CHAR(20),getdate(),101) AS 'MM/DD/YYYY'
    SELECT CONVERT(CHAR(20),getdate(),102) AS 'YYYY.MM.DD'
    SELECT CONVERT(CHAR(20),getdate(),103) AS 'DD/MM/YYYY'
    SELECT CONVERT(CHAR(20),getdate(),104) AS 'DD.MM.YYYY'
    SELECT CONVERT(CHAR(20),getdate(),105) AS 'DD-MM-YYYY'
    SELECT CONVERT(CHAR(20),getdate(),106) AS 'DD mmm YYYY'
    SELECT CONVERT(CHAR(20),getdate(),107) AS 'mmm DD, YYYY'
    SELECT CONVERT(CHAR(20),getdate(),108) AS 'HH:MM:SS'
    SELECT CONVERT(CHAR(20),getdate(),109) AS 'mmm DD YYYY HH:MM:SS'
    SELECT CONVERT(CHAR(20),getdate(),110) AS 'MM-DD-YYYY'
    SELECT CONVERT(CHAR(20),getdate(),111) AS 'YYYY/MM/DD'
    SELECT CONVERT(CHAR(20),getdate(),112) AS 'YYYYMMDD'



    quinta-feira, 31 de julho de 2014 15:06

Todas as Respostas

  • Tente desta forma: 

    Retorna somente a data

    SELECT CONVERT(CHAR(10),data,111) FROM tabela

    Retorna somente a Hora

    SELECT CONVERT(CHAR(10),data,114) FROM tabela

    quarta-feira, 23 de abril de 2014 14:00
  • Ou tambem para retorna somente a Hora

    SELECT CONVERT(CHAR(10),data,108) FROM tabela

    PS: Mais informações sobre o CONVERT

     http://technet.microsoft.com/pt-br/library/ms187928.aspx

    • Marcado como Resposta Diogo Ichiyama quarta-feira, 23 de abril de 2014 14:11
    quarta-feira, 23 de abril de 2014 14:09
  • Só pra registrar outras dicas

    SELECT CONVERT(CHAR(20),getdate(),1) AS 'MM/DD/YY' SELECT CONVERT(CHAR(20),getdate(),2) AS 'YY.MM.DD' SELECT CONVERT(CHAR(20),getdate(),3) AS 'DD/MM/YY' SELECT CONVERT(CHAR(20),getdate(),4) AS 'DD.MM.YY' SELECT CONVERT(CHAR(20),getdate(),5) AS 'DD-MM-YY' SELECT CONVERT(CHAR(20),getdate(),6) AS 'DD mmm YY' SELECT CONVERT(CHAR(20),getdate(),7) AS 'mmm DD, YY' SELECT CONVERT(CHAR(20),getdate(),8) AS 'HH:MM:SS' SELECT CONVERT(CHAR(20),getdate(),9) AS 'mmm DD YYYY HH:MM:SS' SELECT CONVERT(CHAR(20),getdate(),10) AS 'MM-DD-YY' SELECT CONVERT(CHAR(20),getdate(),11) AS 'YY/07/31' SELECT CONVERT(CHAR(20),getdate(),12) AS 'YYMMDD' SELECT CONVERT(CHAR(20),getdate(),13) AS 'DD mmm YYYY HH:MM:SS' SELECT CONVERT(CHAR(20),getdate(),14) AS 'HH:MM:SS:000'

    SELECT CONVERT(CHAR(20),getdate(),101) AS 'MM/DD/YYYY'
    SELECT CONVERT(CHAR(20),getdate(),102) AS 'YYYY.MM.DD'
    SELECT CONVERT(CHAR(20),getdate(),103) AS 'DD/MM/YYYY'
    SELECT CONVERT(CHAR(20),getdate(),104) AS 'DD.MM.YYYY'
    SELECT CONVERT(CHAR(20),getdate(),105) AS 'DD-MM-YYYY'
    SELECT CONVERT(CHAR(20),getdate(),106) AS 'DD mmm YYYY'
    SELECT CONVERT(CHAR(20),getdate(),107) AS 'mmm DD, YYYY'
    SELECT CONVERT(CHAR(20),getdate(),108) AS 'HH:MM:SS'
    SELECT CONVERT(CHAR(20),getdate(),109) AS 'mmm DD YYYY HH:MM:SS'
    SELECT CONVERT(CHAR(20),getdate(),110) AS 'MM-DD-YYYY'
    SELECT CONVERT(CHAR(20),getdate(),111) AS 'YYYY/MM/DD'
    SELECT CONVERT(CHAR(20),getdate(),112) AS 'YYYYMMDD'



    quinta-feira, 31 de julho de 2014 15:06