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

Timestamp field selection using date field

vikash_pathak
Participant
0 Likes
7,123

Hi All,

I am fetching data from VLCHISTORY table ,

in which data has to be selected for todays date , for that TSTMP field has to be used,

and on ABAP report selection screen i have parameter field type of DATUM.

how datum field can be used with TSTMP field for data retrieval.

Please share the solution.

Thanks

Vikash

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
6,023

Just convert the date into two timestamps (at 00:00:00 and 23:59:59) select with database timestamp field between those values?

CONVERT DATE p_date  TIME '000000'
   INTO TIME STAMP low_timestamp
   TIME ZONE sy-zonlo.

CONVERT DATE p_date  TIME '235959'
   INTO TIME STAMP high_timestamp
   TIME ZONE sy-zonlo.

SELECT COUNT(*) FROM vlchistory
   WHERE tstmp BETWEEN low_timestamp AND high_timestamp.<br>

Hi All,

I am fetching data from VLCHISTORY table ,

in which data has to be selected for todays date , for that TSTMP field has to be used,

and on ABAP report selection screen i have parameter field type of DATUM.

how datum field can be used with TSTMP field for data retrieval.

Please share the solution.

Thanks

Vikash

7 REPLIES 7
Read only

0 Likes
6,023

Hi,

In this thread , at first data is being selected from DB table and then data is being deleted from internal table,

i have to filter data while selecting it from DB table itself. otherwise it will return all the record .

Thanks

Read only

6,023

Please check the second answer thread in the link:
https://answers.sap.com/questions/8079633/select-query-on-time-stamp.html

Read only

0 Likes
6,023

It was helpful .

Thanks

Read only

RaymondGiuseppi
Active Contributor
6,024

Just convert the date into two timestamps (at 00:00:00 and 23:59:59) select with database timestamp field between those values?

CONVERT DATE p_date  TIME '000000'
   INTO TIME STAMP low_timestamp
   TIME ZONE sy-zonlo.

CONVERT DATE p_date  TIME '235959'
   INTO TIME STAMP high_timestamp
   TIME ZONE sy-zonlo.

SELECT COUNT(*) FROM vlchistory
   WHERE tstmp BETWEEN low_timestamp AND high_timestamp.<br>
Read only

6,023

fyi typo in code (235859)

Read only

Sandra_Rossi
Active Contributor
6,023

You need to make sure of the time zone of values in VLCHISTORY-TSTMP. Usually it's UTC.

Usually, people will enter the date for their local time zone, so you should convert from user's time zone to VLCHISTORY-TSTMP time zone.

See Raymond answer for more details.