Application Development and Automation 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: 
Read only

Sub String Problem

Former Member
0 Likes
602

Hi All,

I have a date field in UTC date formate in the data base table.

For Ex: 20.080.804.121.334,0000000

YY YY MM DD

I want to compare this date with current system date (Ex 20080804)in the report and want to pull the data from table.

Could you please help me out on this??

Thanks in advance.

Sekhar

1 ACCEPTED SOLUTION
Read only

naimesh_patel
Active Contributor
0 Likes
570

Instead of converting the stored UTC timestamp to normal date before selecting the data, you can fill the range for the required UTC timestamp and select the data based on that range.


DATA: r_utc type range of timestampl,
      l_r_utc like line of r_utc.

DATA: time_stamp TYPE timestampl,
      dat TYPE d,
      tim TYPE t,
      tz   TYPE ttzz-tzone,
      dst(1) TYPE c.

tz = 'CST'.
dat = sy-datum.
tim = '000000'.
CONVERT DATE dat TIME tim
        INTO TIME STAMP l_r_utc-low TIME ZONE tz.

tim = '235959'.
CONVERT DATE dat TIME tim
        INTO TIME STAMP l_r_utc-high TIME ZONE tz.

l_r_utc-sign = 'I'.
l_r_utc-option = 'BT'.
append l_r_utc to r_utc.

SELECT * FROM DBTAB
INTO TABLE ITAB
WHERE UTC_TIME IN R_UTC.

Once you get your data into table, you can use the CONVERT TIME STAMP to get the date and time.


CONVERT TIME STAMP time_stamp TIME ZONE tz
        INTO DATE dat TIME tim DAYLIGHT SAVING TIME dst.
WRITE: /(10) dat, (8) tim, dst.

Regards,

Naimesh Patel

3 REPLIES 3
Read only

Former Member
0 Likes
570

move the field to a character field and tehn take the first 8 bytes for date

Read only

Former Member
0 Likes
570

Hi,

move first 10 characters into one variable.

we can replace '.' with space using Replace all occurence of statement.

we can use condense statement to condense the variable.

Now we can compare two dates.

Regards,

Suresh

Read only

naimesh_patel
Active Contributor
0 Likes
571

Instead of converting the stored UTC timestamp to normal date before selecting the data, you can fill the range for the required UTC timestamp and select the data based on that range.


DATA: r_utc type range of timestampl,
      l_r_utc like line of r_utc.

DATA: time_stamp TYPE timestampl,
      dat TYPE d,
      tim TYPE t,
      tz   TYPE ttzz-tzone,
      dst(1) TYPE c.

tz = 'CST'.
dat = sy-datum.
tim = '000000'.
CONVERT DATE dat TIME tim
        INTO TIME STAMP l_r_utc-low TIME ZONE tz.

tim = '235959'.
CONVERT DATE dat TIME tim
        INTO TIME STAMP l_r_utc-high TIME ZONE tz.

l_r_utc-sign = 'I'.
l_r_utc-option = 'BT'.
append l_r_utc to r_utc.

SELECT * FROM DBTAB
INTO TABLE ITAB
WHERE UTC_TIME IN R_UTC.

Once you get your data into table, you can use the CONVERT TIME STAMP to get the date and time.


CONVERT TIME STAMP time_stamp TIME ZONE tz
        INTO DATE dat TIME tim DAYLIGHT SAVING TIME dst.
WRITE: /(10) dat, (8) tim, dst.

Regards,

Naimesh Patel