Search code examples
datetimexpagesxpages-ssjs

xpages Date Compare


Hi i want to write Style ssjs for plan view. Set on column date variable "01.06.2007" and if document start date + duration contains 01.06.2007 result is background color change.

DateConverter.stringToDate = Java.util.date Tommy Valand code. (http://dontpanic82.blogspot.com.tr/2010/04/xpages-code-snippet-for-datestring.html)

//------------------------------------------------- col = 0;

var zeroDate = DateConverter.stringToDate( '01.06.2007', 'dd.MM.yyyy' ) 

colDate = @Adjust(zeroDate, 0, 0, col, 0, 0, 0);

duration = parseInt(rowData.getColumnValue("Duration"));

startDate = rowData.getColumnValue("Start Date");

endDate = @Adjust(startDate, 0, 0, (duration-1), 0, 0, 0);

if(startDate == colDate){
"startColor"}else if(startDate < coldate && (colDate < endDate)){
"perColor"}else{
"bgColor"}`

Solution

  • You cannot compare date values with < or > AFAIK. Transform your NotesDateTime stuff into Java date objects and use the before() and after() methods. Like

    var startDate:NotesDateTime = ... ;
    if(startDate.toJavaDate().before(colDate.toJavaDate()) && ... ){
    ...
    }