1
votes

I have written a batch job. In this batch job i have a condition to take date > = 1/1/2012 I am not able to give the date in the query. can you please help me.

global Database.QueryLocator start(Database.BatchableContext BC) {

    system.debug('Inside start');

    //date mydate = date.valueof(1/1/2012);
    return Database.getQueryLocator('select  name from opportunity');
}

I have given it in 2 ways 1st is : took the date into a date field and give the condition as date >= :mydate (shows an error in debug log as Invalid date: 0 ) and 2nd way when i gave the date their itself as date >=: 1/1/2012 (it shows as error in debug log as unexpected token: / )

can you please help me

Thanks Anu

1

1 Answers

0
votes

You must follow the proper date format

YYYY-MM-DD

select name from opportunity where mydate >= 2012-01-01

More information here