Welcome to the IBM Collaboration Solutions Community IQJam.
UsernamePassword
Reset Password | Register
   
Home | Leader Board | Tags | Help
How to Display a Date in a computed Field 
On a Custom Control I have a repeat Control that is bound to a NotesView.
 
The second column of the view is a date field. 
 
I can access the date and time with the formula: 
 
rowData.getColumnValues()[1] 
 
If I put this value into a Label control - it displays just fine, however, I can't change the formatting of the date/time.  
 
If I create a computed field then there are options to format the date/time via the "Display Type" dropdown, but my computed field stays blank.  Like there's no value getting in there. 
 
I ASSUME that the issue is that since I'm reading the date in via a view column that it's actually coming in as a String...  I could be wrong.  Ideally I'd rather not drill down to the document using  getDocument() due to the performance hit of accessing the backend document.
 
Any advice would be appreciated. 
 
Thanks! 
Domino Development / XPages
Tagged
David Leedy - about 1 year ago |  |  | Viewed 156 times

There are 2 answers

2votes
Marked as correct on11/5/10 6:52 PM
What you get back out of the view depends on what the view column contains ... if you have the date converted to text, (ie via an @text, it'll be text), other wise it may be a NotesDateTime, possibly a simple date .... either way, you need to get it to a NotesDate Time object, so...
 
// If it's a string then...
var due:NotesDateTime = session.createDateTime("01/01/2001 00:00:00");

// If its a javascript Date object then...
var due:NotesDateTime = session.createDateTime(notesentryvar.getColumnValue(X));

once its a NotesDateTimeObject, you can format the date like this:

I18n.toString(due.toJavaDate(), "M/d/yyyy");
 
 


Jeremy Hodge - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


0votes
Jeremy,
 
Thanks!  That put me on the right track.   I guess the biggest thing I was missing was the NotesDatetime Object stuff and the need to convert to Java.
 
The Answer for anyone who reads this:

I have a Date field in a Notes Document and I'm reading the view into a Repeat Control.  I add a computed field to the repeat control bound to SSJS.  I want to use a computed field to take advantage of the formatting options given to us in the Display Type section of DDE.
 
So the code to make this work is:

var dueDate:NotesDateTime = rowData.getColumnValues()[1];
return commentD.toJavaDate;

I tried the  I18n.toString function that Jeremy suggested and that works also, but since I don't know that very well and I also want to display the date and time component I'm preferring to stick with the formatting options in Designer.
 
 Thanks again Jeremy!


David Leedy - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community