Change Data format

  • Hi Experts,

    We have a datetime field where date time is saved in below format.
    Apr 19 2018  8:57AM

    But  want to update in below format. Is it possible for existing data. All new data format is changed through code.
    2018-04-2018T08:57:00

  • VastSQL - Thursday, April 26, 2018 12:44 AM

    Hi Experts,

    We have a datetime field where date time is saved in below format.
    Apr 19 2018  8:57AM

    But  want to update in below format. Is it possible for existing data. All new data format is changed through code.
    2018-04-2018T08:57:00

    The datetime data type does not store any format, only the date and time values.
    😎

    Have a look at datetime (Transact-SQL)

  • Eirikur Eiriksson - Thursday, April 26, 2018 12:55 AM

    VastSQL - Thursday, April 26, 2018 12:44 AM

    Hi Experts,

    We have a datetime field where date time is saved in below format.
    Apr 19 2018  8:57AM

    But  want to update in below format. Is it possible for existing data. All new data format is changed through code.
    2018-04-2018T08:57:00

    The datetime data type does not store any format, only the date and time values.
    😎

    Have a look at datetime (Transact-SQL)

    Thanks Eirikur

  • VastSQL - Thursday, April 26, 2018 3:05 AM

    Eirikur Eiriksson - Thursday, April 26, 2018 12:55 AM

    VastSQL - Thursday, April 26, 2018 12:44 AM

    Hi Experts,

    We have a datetime field where date time is saved in below format.
    Apr 19 2018  8:57AM

    But  want to update in below format. Is it possible for existing data. All new data format is changed through code.
    2018-04-2018T08:57:00

    The datetime data type does not store any format, only the date and time values.
    😎

    Have a look at datetime (Transact-SQL)

    Thanks Eirikur

    You are welcome.
    😎

  • Eirikur Eiriksson - Thursday, April 26, 2018 12:55 AM

    VastSQL - Thursday, April 26, 2018 12:44 AM

    Hi Experts,

    We have a datetime field where date time is saved in below format.
    Apr 19 2018  8:57AM

    But  want to update in below format. Is it possible for existing data. All new data format is changed through code.
    2018-04-2018T08:57:00

    The datetime data type does not store any format, only the date and time values.
    😎

    Have a look at datetime (Transact-SQL)

    You have a whole bunch of conceptual errors and don't know what how SQL works. Let's start with the basics; a column is not a field. If you want to read the standard you'll see the term field refers to part of a data type display in SQL in SQL columns have datatypes, which are abstracted and have nothing to do with physical storage choices.

    However, the standards also have one and only one display format for daytime data. That format is based on ISO 8601, and looks like "YYYY-MM-DD HH:MM:SS.sss" which you seem to be moving to. The problem is that only put this in the standard, we left out the "T" separator in SQL. Frankly, I wish we had left it in, but that's what we voted on.

    Please post DDL and follow ANSI/ISO standards when asking for help. 

  • As noted, the datetime is stored in a numeric format.

    It's likely that whatever interface is displaying the date to you is putting it in this format:
    Apr 19 2018 8:57AM

    If you want to explicitly generate this format:
    2018-04-2018T08:57:00 
    you can do this:
    SELECT CONVERT(varchar(19), datetime_column, 126)

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.

  • jcelko212 32090 - Monday, April 30, 2018 10:37 AM

    Eirikur Eiriksson - Thursday, April 26, 2018 12:55 AM

    VastSQL - Thursday, April 26, 2018 12:44 AM

    Hi Experts,

    We have a datetime field where date time is saved in below format.
    Apr 19 2018  8:57AM

    But  want to update in below format. Is it possible for existing data. All new data format is changed through code.
    2018-04-2018T08:57:00

    The datetime data type does not store any format, only the date and time values.
    😎

    Have a look at datetime (Transact-SQL)

    You have a whole bunch of conceptual errors and don't know what how SQL works. Let's start with the basics; a column is not a field. If you want to read the standard you'll see the term field refers to part of a data type display in SQL in SQL columns have datatypes, which are abstracted and have nothing to do with physical storage choices.

    However, the standards also have one and only one display format for daytime data. That format is based on ISO 8601, and looks like "YYYY-MM-DD HH:MM:SS.sss" which you seem to be moving to. The problem is that only put this in the standard, we left out the "T" separator in SQL. Frankly, I wish we had left it in, but that's what we voted on.

    Jeez, Joe... how many time do I have to prove to you that the format you're touting as the "one and only one display format for daytime data" is actually an alternate format that is allow and that the original format in the ISO 8601 standard does NOT include any dashes.  There's also the problem of different language basis being used in SQL Server will also swap MM-DD in your supposed air tight format.  Of course, I've proven that several times as well but you seem to be stuck on some very bad information.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden - Monday, April 30, 2018 11:54 AM

    jcelko212 32090 - Monday, April 30, 2018 10:37 AM

    Eirikur Eiriksson - Thursday, April 26, 2018 12:55 AM

    VastSQL - Thursday, April 26, 2018 12:44 AM

    Hi Experts,

    We have a datetime field where date time is saved in below format.
    Apr 19 2018  8:57AM

    But  want to update in below format. Is it possible for existing data. All new data format is changed through code.
    2018-04-2018T08:57:00

    The datetime data type does not store any format, only the date and time values.
    😎

    Have a look at datetime (Transact-SQL)

    You have a whole bunch of conceptual errors and don't know what how SQL works. Let's start with the basics; a column is not a field. If you want to read the standard you'll see the term field refers to part of a data type display in SQL in SQL columns have datatypes, which are abstracted and have nothing to do with physical storage choices.

    However, the standards also have one and only one display format for daytime data. That format is based on ISO 8601, and looks like "YYYY-MM-DD HH:MM:SS.sss" which you seem to be moving to. The problem is that only put this in the standard, we left out the "T" separator in SQL. Frankly, I wish we had left it in, but that's what we voted on.

    Jeez, Joe... how many time do I have to prove to you that the format you're touting as the "one and only one display format for daytime data" is actually an alternate format that is allow and that the original format in the ISO 8601 standard does NOT include any dashes.  There's also the problem of different language basis being used in SQL Server will also swap MM-DD in your supposed air tight format.  Of course, I've proven that several times as well but you seem to be stuck on some very bad information.

    If I understand the standard correctly, the non-dashed version is the standard for dates (without the time component) while the dashed version is the standard when there is a time component. 
    YYYYMMDD
    vs
    YYYY-MM-DD hh:mm:ss.nnnnnnn

  • Jason A. Long - Monday, April 30, 2018 12:32 PM

    Jeff Moden - Monday, April 30, 2018 11:54 AM

    jcelko212 32090 - Monday, April 30, 2018 10:37 AM

    Eirikur Eiriksson - Thursday, April 26, 2018 12:55 AM

    VastSQL - Thursday, April 26, 2018 12:44 AM

    Hi Experts,

    We have a datetime field where date time is saved in below format.
    Apr 19 2018  8:57AM

    But  want to update in below format. Is it possible for existing data. All new data format is changed through code.
    2018-04-2018T08:57:00

    The datetime data type does not store any format, only the date and time values.
    😎

    Have a look at datetime (Transact-SQL)

    You have a whole bunch of conceptual errors and don't know what how SQL works. Let's start with the basics; a column is not a field. If you want to read the standard you'll see the term field refers to part of a data type display in SQL in SQL columns have datatypes, which are abstracted and have nothing to do with physical storage choices.

    However, the standards also have one and only one display format for daytime data. That format is based on ISO 8601, and looks like "YYYY-MM-DD HH:MM:SS.sss" which you seem to be moving to. The problem is that only put this in the standard, we left out the "T" separator in SQL. Frankly, I wish we had left it in, but that's what we voted on.

    Jeez, Joe... how many time do I have to prove to you that the format you're touting as the "one and only one display format for daytime data" is actually an alternate format that is allow and that the original format in the ISO 8601 standard does NOT include any dashes.  There's also the problem of different language basis being used in SQL Server will also swap MM-DD in your supposed air tight format.  Of course, I've proven that several times as well but you seem to be stuck on some very bad information.

    If I understand the standard correctly, the non-dashed version is the standard for dates (without the time component) while the dashed version is the standard when there is a time component. 
    YYYYMMDD
    vs
    YYYY-MM-DD hh:mm:ss.nnnnnnn

    That's not correct.  I can't post a quote from section "4.3.2 Complete representations" of the standard because of the way the damned copyright is written but it clearly states that both forms are allowed whether or not the time is included or not.  Basically, if you include the dashes in the date, the "extended format" says that you should also use colons in the time and the "T" separator is optional by agreement.  If dashes are not included in the date, then the "basic format" does not include the colons in the time.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • This was removed by the editor as SPAM

Viewing 10 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply