Announcement

Collapse
No announcement yet.

Konvertierung Nummeric zu Time / Date

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Konvertierung Nummeric zu Time / Date

    Hallo, laut der SQL Reference ist es möglich, vom Datentype numeric zu Time zu convertieren leider laufen meine ganzen befehle in einen Error über.
    Converts a column from one datatype to another. Available in SQL, DSQL, and isql.

    Syntax CAST (value AS datatype)

    Argument Description
    val A column, constant, or expression; in SQL, val can also be a host-language variable, function, or UDF
    datatype Datatype to which to convert
    *

    Description CAST() allows mixing of numerics and characters in a single expression by converting val to a specified datatype.

    Normally, only similar datatypes can be compared in search conditions. CAST() can be used in search conditions to translate one datatype into another for comparison purposes.
    Datatypes can be converted as shown in the following table:

    TABLE 2 Compatible datatypes for CAST()

    *

    From datatype class To datatype class
    Numeric character, varying character, date, time, timestamp
    Character, varying character numeric, date, time, timestamp
    Date character, varying character, timestamp
    Time character, varying character, timestamp
    Timestamp character, varying character, date, time
    Blob, arrays —
    *

    An error results if a given datatype cannot be converted into the datatype specified in CAST().

    Example In the following WHERE clause, CAST() is used to translate a CHARACTER datatype, INTERVIEW_DATE, to a DATE datatype to compare against a DATE datatype, HIRE_DATE:

    . . .
    WHERE HIRE_DATE = CAST (INTERVIEW_DATE AS DATE);

    See Also UPPER(*)
    ich hätte es gerne von Numeric also die Sekunden oder halt im Tageformat also 12 Uhr wäre dann 0,5 bzw 0.5. leider bekomme ich über

    Dynamic SQL Error
    SQL error code = -104
    Unexpected end of command
    Statement: select cast(50 as Time)

    den fehler


    Dynamic SQL Error
    SQL error code = -104
    Unexpected end of command
    Statement: select cast(0.5 as Time)

    Kann es sein, das 0,5 keins ist oder ich was anderes tuen muss?

    TO_TIME(value) geht auch nicht und ich brauch doch lediglich für die Anzeige, er soll damit nichtmal weiterechnen.

  • #2
    Was soll aus 0,5 werden?

    Comment

    Working...
    X