Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Date & Time format conversation

Former Member
0 Kudos
933

Hi,

How to convert date and time format ?

i.e input date 05/05/2009 input time 00:00:00

output date 05052009. output time 000000

I want to give the output date & time formate to my BAPI field. Is there any FM for convert date & time format.

thanks & regards

santhosh.

1 ACCEPTED SOLUTION

former_member555112
Active Contributor
0 Kudos
220

hi,

You can make us of offsets to convert the date in YYYYMMDD format if the date is separated by '/'

or you can also make use of split statement.

The FM to convert date to internal format is 'CONVERT_DATE_TO_INTERNAL'

Regards,

Ankur Parab

8 REPLIES 8

Former Member
0 Kudos
220

Dear santosh

Take the date and time vales in to some variables and use the below syntax.(please check for the syntax)

REPLACE all occurances of '/' in l_date by space.

REPLACE all occurances of '/' in l_time by space.

condense l_date.

condense l_time.

Hope it helps.

Give points before closing the question.

Regards

Akmal

former_member555112
Active Contributor
0 Kudos
221

hi,

You can make us of offsets to convert the date in YYYYMMDD format if the date is separated by '/'

or you can also make use of split statement.

The FM to convert date to internal format is 'CONVERT_DATE_TO_INTERNAL'

Regards,

Ankur Parab

0 Kudos
220

what is 'CONVERT_DATE_TO_INTERNAL' how do you use this in Webi report ?

we ahve a problem with this prompt

to_date( @Prompt('Enter Start Date (mm/dd/yyyy format):','D','Prompts\Current Day',mono,free,Not_Persistent,,User:1),'mm/dd/yyyy hh:mi:ss am')

I entered date and time as specified in the format here, mm/dd/yyyy hh:mi:ss am', value like '3/26/2009 12:00:00 am', Webi is complaining with WIS message, 'invalid month', it is seeing month as 26 instead of 3, so I made it 26/3/2009 12:00:00 am, now it is complaining 'invalid time ... time must be between 12 and 0', what should be the time format I enter ?

0 Kudos
220

what is 'CONVERT_DATE_TO_INTERNAL' how do you use this in Webi report ?

we ahve a problem with this prompt

to_date( @Prompt('Enter Start Date (mm/dd/yyyy format):','D','Prompts\Current Day',mono,free,Not_Persistent,,User:1),'mm/dd/yyyy hh:mi:ss am')

I entered date and time as specified in the format here, mm/dd/yyyy hh:mi:ss am', value like '3/26/2009 12:00:00 am', Webi is complaining with WIS message, 'invalid month', it is seeing month as 26 instead of 3, so I made it 26/3/2009 12:00:00 am, now it is complaining 'invalid time ... time must be between 12 and 0', what should be the time format I enter ?

Former Member
0 Kudos
220

Hi,

Simply write a small piece code for it like:

say date1= 05/05/2009.

use:

CONCATENATE date1+0(2)
            date1+3(2)
            date1+6(4)
            INTO date2.

date2 will be 05052009.

Similarly for the time also.

Regards.

naveen_inuganti2
Active Contributor
0 Kudos
220

Hi,

[Click here|https://wiki.sdn.sap.com/wiki/display/ABAP/ABAPFunctionModules]

--Naveen Inuagnti.

Former Member
0 Kudos
220

Hi,

You can convert in following ways

SET TIME MASK: CONTROLS THE THE TIME FIELD FORMAT.

SET DATE MASK: CONTROLS THE DATE FIELD FORMAT.

eg: Set Time mask = ''HH.MM.SS'

Regards

Sathish

Former Member
0 Kudos
220

Hi,

Assign the date toa variable

say befdate= 05/05/2009.

the u can use like this:

CONCATENATE befdate+0(2)

befdate+3(2)

befdate+6(4)

INTO aftdate.

similarly u can do for time also.

Regards