You need to sign in to do that
Don't have an account?
Satya413
Strip Time from Date Field
Hello Everyone,
I would like to strip the time of the dynamically referenced date field as shown below. Any help is appreciated.
Controller:
public class examschedule1_con {
public exam_schedule__c es {get; set;}
public list<exam_schedule__c> ess {get; set;}
public map<string,list<date>> maplist{get; set;}
public examschedule1_con()
{
es = new exam_schedule__c();
}
public void getdata()
{
maplist = new map<string,list<date>>();
ess = [select name, startdate__c, enddate__c, starttime__c, endtime__c, year__c, examtype__c,
subject1__c, subject2__c, subject3__c, subject4__c, subject5__c, subject6__c, subject7__c
from exam_schedule__c where year__c = :es.year__c ];
for(exam_schedule__c e : ess)
{
if(!maplist.containskey(e.examtype__c))
maplist.put(e.examtype__c,new list<date>());
maplist.get(e.examtype__c).add(e.subject1__c);
maplist.get(e.examtype__c).add(e.subject2__c);
maplist.get(e.examtype__c).add(e.subject3__c);
maplist.get(e.examtype__c).add(e.subject4__c);
maplist.get(e.examtype__c).add(e.subject5__c);
maplist.get(e.examtype__c).add(e.subject6__c);
maplist.get(e.examtype__c).add(e.subject7__c);
}
}
}
VF Page:
<apex:page controller="examschedule1_con" showHeader="false">
<apex:form >
<apex:pageBlock >
<apex:pageblockSection title="Enter Exam Details">
<apex:inputfield value="{!es.Year__c}"/>
<apex:commandButton value="Submit" action="{!getdata}"/>
</apex:pageblocksection>
</apex:pageblock>
<table border="1" width="600" align="center">
<th>Exam Type</th>
<th>Subject1</th>
<th>Subject2</th>
<th>Subject3</th>
<th>Subject4</th>
<th>Subject5</th>
<th>Subject6</th>
<th>Subject7</th>
<apex:repeat value="{!maplist}" var="key">
<tr>
<td>{!key}</td>
<apex:repeat value="{!maplist[key]}" var="value">
<td>{!value}</td>
</apex:repeat>
</tr>
</apex:repeat>
</table>
</apex:form>
</apex:page>
My Output:
Thank you,
Satya
I would like to strip the time of the dynamically referenced date field as shown below. Any help is appreciated.
Controller:
public class examschedule1_con {
public exam_schedule__c es {get; set;}
public list<exam_schedule__c> ess {get; set;}
public map<string,list<date>> maplist{get; set;}
public examschedule1_con()
{
es = new exam_schedule__c();
}
public void getdata()
{
maplist = new map<string,list<date>>();
ess = [select name, startdate__c, enddate__c, starttime__c, endtime__c, year__c, examtype__c,
subject1__c, subject2__c, subject3__c, subject4__c, subject5__c, subject6__c, subject7__c
from exam_schedule__c where year__c = :es.year__c ];
for(exam_schedule__c e : ess)
{
if(!maplist.containskey(e.examtype__c))
maplist.put(e.examtype__c,new list<date>());
maplist.get(e.examtype__c).add(e.subject1__c);
maplist.get(e.examtype__c).add(e.subject2__c);
maplist.get(e.examtype__c).add(e.subject3__c);
maplist.get(e.examtype__c).add(e.subject4__c);
maplist.get(e.examtype__c).add(e.subject5__c);
maplist.get(e.examtype__c).add(e.subject6__c);
maplist.get(e.examtype__c).add(e.subject7__c);
}
}
}
VF Page:
<apex:page controller="examschedule1_con" showHeader="false">
<apex:form >
<apex:pageBlock >
<apex:pageblockSection title="Enter Exam Details">
<apex:inputfield value="{!es.Year__c}"/>
<apex:commandButton value="Submit" action="{!getdata}"/>
</apex:pageblocksection>
</apex:pageblock>
<table border="1" width="600" align="center">
<th>Exam Type</th>
<th>Subject1</th>
<th>Subject2</th>
<th>Subject3</th>
<th>Subject4</th>
<th>Subject5</th>
<th>Subject6</th>
<th>Subject7</th>
<apex:repeat value="{!maplist}" var="key">
<tr>
<td>{!key}</td>
<apex:repeat value="{!maplist[key]}" var="value">
<td>{!value}</td>
</apex:repeat>
</tr>
</apex:repeat>
</table>
</apex:form>
</apex:page>
My Output:
Thank you,
Satya
If you want to display the time from dateTime /date field then refer below code .. which will give you the clear idea.
And one more thing as you are displaying date field so that field always have time = 00 .. so if you want to diisplay the time then you can use dataTime field.
please let me know if this will help
Thanks,
Keyur Modi
All Answers
If you want to display the time from dateTime /date field then refer below code .. which will give you the clear idea.
And one more thing as you are displaying date field so that field always have time = 00 .. so if you want to diisplay the time then you can use dataTime field.
please let me know if this will help
Thanks,
Keyur Modi
Thanks for your reply. Actually, I put the question somewhat unclear. I actually want to take the time away and display only the date from the date field.
Thank you,
Satya
you can do the same with code which i shared .. just chane it as mention below
please let me know if this will help,
Thanks,
Keyur Modi
Thank You,
Satya