Skip to Content
avatar image
Former Member

compare only month part of a date field in the where clause

hi friends i want to select all the records in the table IMRG where the month part in date field IDATE is a particular month.This month is stored in a variable.and is not constant.

like :

select * from IMRG where IDATE +4(2) = var_month

but in above case there is error "field IDATE +4(2) is sunknown "

here var_month stores the month for wich i have to select records from the table.

ihave tried :

select * from IMRG where IDATE like '____var_month__'

but it is not working and giving runtym error as expected.my problem is that the month is stored in a var.

Plz help .

Edited by: achalmehra on Jun 25, 2010 9:54 AM

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Jun 25, 2010 at 08:20 AM

    Hello

    Try like this:

    data: p_idate like imrg-idate.
    concatenate '____' var_month '__' into p_idate.
    select * from IMRG where IDATE like p_idate
    

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 25, 2010 at 08:15 AM

    use this code

    data itab type standard table of imrg.

    select * from IMRG into table itab where IDATE GT '19950601' and IDATE LT '19950630'.

    Add comment
    10|10000 characters needed characters exceeded