You need to sign in to do that
Don't have an account?
abhishek_pandey1989@yahoo.com
Soql Order By no working correctly on datetime field
I have a inner soql query in which i am trying to get results order by a date field mentioned below in code
Please help
Thanks in advance
map<id,contact> conmap=new map<id,contact>([SELECT Id, (SELECT Status,Subject,ActivityDate FROM Tasks ORDER by ActivityDate ) FROM Contact where id=:conid]);
Can you try after putting ASC or DESC keyword? Also share what results you are getting.
Asc and desc does makes changes but is not giving me the correct results .....developer console ....
I have three dates (And as u can see below these are not sorted)
In DESC I get
15:43:41:057 USER_DEBUG [18]|DEBUG|+++conmap++++2013-04-26 00:00:00
15:43:41:057 USER_DEBUG [18]|DEBUG|+++conmap++++2013-06-11 00:00:00
15:43:41:058 USER_DEBUG [18]|DEBUG|+++conmap++++2013-03-26 00:00:00
In Asc I Get
15:45:28:042 USER_DEBUG [18]|DEBUG|+++conmap++++2013-04-26 00:00:00
15:45:28:043 USER_DEBUG [18]|DEBUG|+++conmap++++2013-03-26 00:00:00
15:45:28:043 USER_DEBUG [18]|DEBUG|+++conmap++++2013-06-11 00:00:00
THanks again
SELECT Status,Subject,ActivityDate FROM Tasks ORDER by ActivityDate ) and see the result...?
problem sorted
Just in case anyone else stumbles accross this - it appears that sorting in this instance failed because it was done in a map. If you do this for a list, it works just fine.