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

Query regarding Date

Former Member
0 Likes
616

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
Read only

Former Member
0 Likes
594

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
Read only

Former Member
0 Likes
595

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> ).

Read only

0 Likes
594

Hi Manoj,

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

Thanks,

Deep.

Read only

0 Likes
594

Yes. you can.

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

Read only

anversha_s
Active Contributor
0 Likes
594

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

Read only

Former Member
0 Likes
594
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.