Skip to Content
avatar image
Former Member

Convert float to date

Hello everyone,

I need to convert "2.006123100000000E+07" to a date format.

How can I do it ?

Thanks in advance.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    May 29, 2006 at 12:47 PM

    Hello David,

    You could it like this:

    DATA:

    zlv_float TYPE f VALUE '2.006123100000000E+07',

    zlv_integer TYPE i,

    zlv_date TYPE d.

    zlv_integer = zlv_float.

    write zlv_integer to zlv_date.

    Regards,

    John.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member
      REPORT  ychatest                                .
      
      DATA : p_float TYPE f,
             p_date LIKE cawn-atwrt,
             p_flt LIKE cawn-atflv,
             p_dt LIKE sy-datum.
      .
      
      p_float = '2.006123100000000E+07'.
      p_flt = p_float.
      
      CALL FUNCTION 'CTCV_CONVERT_FLOAT_TO_DATE'
        EXPORTING
          float = p_flt
        IMPORTING
          date  = p_date.
      
      WRITE : p_date TO p_dt DD/MM/YYYY.
      
      WRITE : p_dt.
  • avatar image
    Former Member
    May 29, 2006 at 12:42 PM

    JUST EDITED THIS ONE, NOW U GET THE VALUE INTO THE STRING>>>

    REPORT GEN.
    DATA : float TYPE f.
    
    DATA : string(15) TYPE c.
    
    float = '21.12345'.
    
    CALL FUNCTION 'FLTP_CHAR_CONVERSION'
    EXPORTING
    DECIM = 0
    * EXPON = 0
    input = float
    * IVALU = ' '
    * MASKN = ' '
    IMPORTING
    flstr = string
    .
    
    WRITE :/ float.
    WRITE :/ string.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 29, 2006 at 12:48 PM

    hi ,

    use convert key word.

    that is

    syntax

    CONVERT TIME STAMP tst TIME ZONE tz INTO DATE d TIME t.

    Example

    CONVERT TIME STAMP lv_timestamp TIME ZONE SY-ZONLO INTO DATE d TIME t.

    lv_timestamp type should be TIMESTAMP or TIMESTAMPL,

    Mark Helpfull answers

    Reagrds

    Mark Helfull answers.

    Add comment
    10|10000 characters needed characters exceeded