function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
viv1viv1 

Sorting according to date and name !

i want to sort values to popolate in piclist in soql..

sort is done using date(date time ) and then name(string)

i have written a query but its not working

 ===> order by CreatedDate,company__c

Vinit_KumarVinit_Kumar

Can you post th whole code so that we can help.

viv1viv1

SELECT Company__c, ContactID__c, CreatedDate,name FROM Payee__c order by CreatedDate,company__c

Vinit_KumarVinit_Kumar

What is not working for you,I tried the below query and it is working for me :-

 

SELECT CreatedDate,name FROM Account order by CreatedDate,name

viv1viv1

created date is in date time format...

i want to sort data as...first it should be sorted through date... n then fields having same date...should be sorted through name !!

but in date time field...it is considering 2 fields having similar date but diffrent time....difrent fields...

Vinit_KumarVinit_Kumar

CreatedDate would not work here,create a formula field where you will convert DateTime field into 
Date field(Conert CreatedDate value in Date using that field) and then use that in your query.