ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

timestamp format differences ...

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

  • timestamp format differences ...

    Any idea why Father Ted behaves differently?

    Code:
    select                                                        
        cast(current date as timestamp) as ThisTS,                
        cast('0001-01-01-00.00.00.000000' as timestamp) as NullTS,
        timestamp('0001-01-01-00.00.00.000000') as AnotherTS,     
        timestamp(current date) as Father_TED,                    
        current timestamp as CurTS,                               
        cast(current date as timestamp) + 185 minutes as yoghurt  
    from SYSIBM/SYSDUMMY1
    All of the other timestamps have the .mmmmmm millisecond component to them except for FT ????

    Thought it was odd myself.

    GC
    Greg Craill: "Life's hard - Get a helmet !!"

  • #2
    Exerpt from the SQL Reference for the TIMESTAMP scalar function:

    The other rules depend on whether the second argument is specified:
    - If both arguments are specified and the second argument is expression-2:
    The result is a TIMESTAMP(6) with the date specified by the first argument and the time specified by the second argument. The fractional seconds part of the timestamp is zero.
    - If both arguments are specified and the second argument is precision-constant:
    The result is a timestamp with the precision specified by the second argument.
    - If only one argument is specified and it is a TIMESTAMP(p):
    The result is a TIMESTAMP(p).
    - If only one argument is specified and it is a DATE:
    The result is that date with an assumed time of midnight cast to TIMESTAMP(0).

    - If only one argument is specified and it is a string:
    The result is the TIMESTAMP(6) represented by that string. If the argument is a string of length 14, the timestamp has a fractional seconds part of zero.


    Birgitta

    Comment

    Working...
    X