locked
Get current date RRS feed

  • Question

  • Strange thing here, in a view i want to add a column with the current date, format needs to be europ.

    select 
    CONVERT(date ,getdate(),103) as datum

    Result:

    2015-01-22

    I would expect it as:

    22-01-2015

    What's going wrong here?

    Thursday, January 22, 2015 8:33 AM

Answers

  • Please try


    select
    CONVERT(varchar(10) ,getdate(),103) as datum

    Note: datetime is not having any format, only when converting to string, it gives format

    • Edited by Mohd Moinuddin Thursday, January 22, 2015 8:42 AM comment
    • Proposed as answer by Satheesh Variath Thursday, January 22, 2015 8:55 AM
    • Marked as answer by MVP_88 Thursday, January 22, 2015 9:40 AM
    Thursday, January 22, 2015 8:41 AM

All replies

  • Please try


    select
    CONVERT(varchar(10) ,getdate(),103) as datum

    Note: datetime is not having any format, only when converting to string, it gives format

    • Edited by Mohd Moinuddin Thursday, January 22, 2015 8:42 AM comment
    • Proposed as answer by Satheesh Variath Thursday, January 22, 2015 8:55 AM
    • Marked as answer by MVP_88 Thursday, January 22, 2015 9:40 AM
    Thursday, January 22, 2015 8:41 AM
  • Refer:  CAST and CONVERT (Transact-SQL)

    SELECT CONVERT(varchar(10) ,getdate(),105) as datum


    -Vaibhav Chaudhari

    Thursday, January 22, 2015 8:43 AM
  • You have data type "date" and a date don't have a specific Format; it's always the frontend which formats the date; and SSMS uses ISO Format for representing dates.

    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    Thursday, January 22, 2015 8:47 AM