cancel
Showing results for 
Search instead for 
Did you mean: 

how to validate date and time ?

Former Member
0 Kudos

Hii while im displaying date and time it is showing without any seperators ??

is there any fm to convert or date from external format to internal format ?

the format which im getting  is 121312 but i need with seperators ?

and the same for time also ?

Thanks in Advance

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Lokeswar,

Use this FM's

Date :  FORMAT_DATE_4_OUTPUT    [ gives date as MM/DD/YY format ]

Time : L_MC_TIME_DIFFERENCE      [ Find the time difference between two date/time ]

and aslo check this link [ function modules related to date and time ]

http://wiki.sdn.sap.com/wiki/display/ABAP/Useful+ABAP+Function+Modules

Regards,

Sushiptha

Former Member
0 Kudos

hi sushiptha ..

    thanks a lot my problem is solved..

Former Member
0 Kudos

Welcome

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi ,

For date depending on your settings in su01 you can display date in the same format using below mentioned code:

      select single datfm from usr01
         into gdf_datfm
        where bname = sy-uname.
      if sy-subrc eq 0.

         endif.

.........................................

  

        case gdf_datfm.

          when '1'.
            concatenate ldf_field+6(2) lcf_dot ldf_field+4(2) lcf_dot ldf_field+0(4) into ldf_date.
            condense ldf_date no-gaps.

          when '2'.
            concatenate ldf_field+4(2) lcf_slash ldf_field+6(2) lcf_slash  ldf_field+0(4) into ldf_date.
            condense ldf_date no-gaps.

          when '3'.
            concatenate ldf_field+4(2) lcf_dash  ldf_field+6(2) lcf_dash  ldf_field+0(4) into ldf_date.
            condense ldf_date no-gaps.

          when '4'.
            concatenate ldf_field+0(4) lcf_dash ldf_field+4(2) lcf_dash ldf_field+6(2) into ldf_date.
            condense ldf_date no-gaps.

          when '5'.
            concatenate ldf_field+0(4) lcf_slash ldf_field+4(2) lcf_slash ldf_field+6(2) into ldf_date.
            condense ldf_date no-gaps.
        endcase.

Thanks ,

Neha

Phillip_Morgan
Contributor
0 Kudos

Not much detail as to where this is all taking place but since your topic is webdynpro, I gather we are talking about... web dynpro.

Well I have very little experience with webdynpro but it cannot be all that different from normal dynpro in these terms.

You need to define a date field or a time field and the system will do all the checking for you. In a normal dynpro, a date field also gets a calendar when you hit F4.

Former Member
0 Kudos

Hi,

You must use data type DATS for the attribute in the context node. In this case, date will be displayed with seperators.

Former Member
0 Kudos

And for Time use TIMS.

Former Member
0 Kudos

hi sachdeva..

i have used the same datatypes ..

but while in output i have to display a message with this fileds ..

at the time it showing without seperators..

any other solution...

Former Member
0 Kudos

Hi,

For displaying these in a message, you would not have a direct solution. For a message can only contain strings, You will have to use String operations.

They are very well exlained by Neha in her post below on how to concatenate your own seperator in a string to display it like a date or time.