Data Type

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • worlman385@yahoo.com

    #1

    Data Type

    I have data look like follows to tell the Date + Time

    2008-03-20T04:30:00Z

    Does SQLServer has a datatype to store directly from the above format
    (Date + Time)

    ==============

    Any datatype to store duration like (1 hour 30 min)

    01H30M
  • David Portas

    #2
    Re: Data Type

    <worlman385@yah oo.comwrote in message
    news:q6ceu3p1a4 57b2kpsqct36nbp rlpmd05j8@4ax.c om...
    >I have data look like follows to tell the Date + Time
    >
    2008-03-20T04:30:00Z
    >
    Does SQLServer has a datatype to store directly from the above format
    (Date + Time)
    >
    ==============
    >
    Any datatype to store duration like (1 hour 30 min)
    >
    01H30M

    Dates and times don't have any format in SQL Server. They are just values.
    However, if you have a *string* in the form '2008-03-20T04:30:00Z' you can
    convert it to a DATETIME value like this:

    SELECT CAST('2008-03-20T04:30:00Z' AS DATETIME);

    You cannot store any time zone component with a DATETIME in SQL Server 2005.
    You can in 2008 using the DATETIMEOFFSET type.

    Duration is just a scalar value in some base units (such as seconds or
    minutes). Use a numeric type for durations.

    --
    David Portas


    Comment

    Working...