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: 

Query regarding Date

Former Member
0 Kudos

Hi All,

I have a issue regarding date.

I have 3 fields in my D.B.Table

<b>Field1, Field2 and DATE</b> Fields.

Now with select query i want to retrieve Field1 & Field2 For Latest Date in DATE field!

Can anybody give solution!

Thanks in advance.

Thanks,

Deep.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Use this code.

select single fld1 fld2 from <table>
         into (v_fld1, v_fld2)
         where date eq ( select max( date ) from <table> ).

or 

select single fld1 fld2 from <table>
         into table gt_fields
         where date eq ( select max( date ) from <table> ).

5 REPLIES 5

Former Member
0 Kudos

Use this code.

select single fld1 fld2 from <table>
         into (v_fld1, v_fld2)
         where date eq ( select max( date ) from <table> ).

or 

select single fld1 fld2 from <table>
         into table gt_fields
         where date eq ( select max( date ) from <table> ).

0 Kudos

Hi Manoj,

I can use another condition NAME EQ '' in where condition right!

Thanks,

Deep.

0 Kudos

Yes. you can.

select fld1 fld2
....
where date eq ( select max( date ) ... ) 
and    name eq p_name.

anversha_s
Active Contributor
0 Kudos

hi,

1 . fetch all the records into an itab.

2. sort that itab by date

3. so the latest record will come in top.

4. take Field1, Field2 from that.

Regards

anver

Former Member
0 Kudos
Select date field1 field2
           from xxxx
           into table itab.

if sy-subrc = 0.
 sort itab descending by date.
 Read itab with key index 1.
endif.