You need to sign in to do that
Don't have an account?
thomsant
Date Formating - urgent
Hi All, Need one help below I am trying to query the Lastupdated Field and then store it in a variable and then use it in another query to fetch record from another object , below is the query used Datetime Dt = [SELECT LastModifiedDate FROM MigrationDate__c order by LastModifiedDate desc Limit 1].LastModifiedDate; The above query returns something like 2011-12-20 00:33:56 but when I use this in another query it does not work and I guess it expects the date values as 2011-12-20T00:33:56.000Z . Do you know how can I use it in the query or is there any function ? pls let me know Regards Tom
Hi Tom,
I tried to use that datetime value in where clause of another query and it run well & returned me correct record. below is the code snipet i tried:
Account a1 = [SELECT Id, LastModifiedDate FROM Account order by LastModifiedDate desc Limit 1];
Datetime Dt = a1.LastModifiedDate;
String accId = a1.Id;
System.debug('Dt ::::::::::::::::' + Dt);
System.debug('Id ::::::::::::::::' + accId);
Account a2 = [Select Id From Account Where LastModifiedDate = :Dt];
System.debug('Retrieved Id :::::::::::::::::' + a2.Id);
here a2.Id returned the same id (a1.Id).
Let me know if you are facing something else.
Thanks,
Ranjeet
All Answers
Hi Tom,
I tried to use that datetime value in where clause of another query and it run well & returned me correct record. below is the code snipet i tried:
Account a1 = [SELECT Id, LastModifiedDate FROM Account order by LastModifiedDate desc Limit 1];
Datetime Dt = a1.LastModifiedDate;
String accId = a1.Id;
System.debug('Dt ::::::::::::::::' + Dt);
System.debug('Id ::::::::::::::::' + accId);
Account a2 = [Select Id From Account Where LastModifiedDate = :Dt];
System.debug('Retrieved Id :::::::::::::::::' + a2.Id);
here a2.Id returned the same id (a1.Id).
Let me know if you are facing something else.
Thanks,
Ranjeet
Thanks Rajeeth its working i need to test using the apex scheduler and see if i face any issues for bulk data import