FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.



Oct 5, 2015, 12:37 PM
51 Posts
topic has been resolvedResolved

Listing of days (Date range)

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 8.5.3
  • Role: Administrator,Developer
  • Tags: Date range,dates
  • Replies: 6

Hi All,

first of all I am Sorry to disturb you guys.

I have one leave request application, where i am saving my leaves selecting from date and to date using date picker control.
my query is i want to list my leave days including from date to till to date in a computed field.


Am feeling some difficulties to compare using date.

How can I make these ?

Thanks in advance.

 

Oct 5, 2015, 5:57 PM
453 Posts
Do you have any sample code?

Dates can be a really big pain.  Are you using javascript or java? 

Post your code to this point 

Oct 5, 2015, 9:55 PM
110 Posts
Are you trying to do something like following?

Oct 6, 2015, 2:24 AM
51 Posts
Listing of days

Many thanks for the prompt reply.

I am trying to implement using SSJS. 

Baxter Jimuk, You are completely right what i am planning to do.

 

Oct 6, 2015, 7:09 AM
589 Posts
hmm

Typically what i do is figure out the formula I need first in the Notes Client.  Just search the view in the database.  That's pretty much the same formula you'll use with the domino object model in SSJS.  You would just need to turn it into a proper string and pass into a search method.

Suggest you get the formula first - get it working then tackle the SSJS.

Oct 6, 2015, 9:58 AM
26 Posts
I would have said @explode
but that doesn't do date ranges in Xpages, so I found this

http://www.notesninjas.com/A555F9/nn.nsf/b2b6ed1db864a76080256ada006da907/a17c83e1e12d29878025786c0054788f!OpenDocument

var Start_Date = getComponent("Start_Date").getValue();
var End_Date = getComponent("End_Date").getValue();

// Only update if End Date is not nothing, assume Start_Date is set to today
if (@Text(End_Date)!="")
{
 
dDatebetween=new Date(Start_Date.getTime());
var dts="";

while (dDatebetween.getTime() <= End_Date.getTime())
 {

   dts=dts+(@Right("0"+@Text(@Day(dDatebetween)),2)+"/"+@Right("0"+@Text(@Month(dDatebetween)),2)+"/"+@Right(@Text(@Year(dDatebetween)),2))+",";

   dDatebetween=new Date(dDatebetween.getTime()+86400000)
 }

getComponent("HolDates").setValue(@Left(dts,@Length(dts)-1));
Oct 6, 2015, 10:22 AM
51 Posts
Listing of days (Date range)

Thanks for all,

I got it from below link.

http://stackoverflow.com/questions/16352792/check-date-range-vs-some-other-date-ranges-for-missing-days

 

var dateArray = new Array();

//Get the date
var AbsenctSince:NotesDateTime = session.createDateTime(document1.getItemValue("from").toString().substr(0,19));
var endDate:NotesDateTime = session.createDateTime(document1.getItemValue("to").toString().substr(0,19));

//Get all days between two dates
dateArray = getDates(AbsenctSince, endDate);

 

 

and then add below function code,

 

function getDates(startDate:NotesDateTime, endDate:NotesDateTime)
{
    var dateArray = new Array();
    var currentDate:NotesDateTime = startDate;
    while (endDate.timeDifference(currentDate) > -1)
    {
        dateArray.push( currentDate.getDateOnly() );
        currentDate.adjustDay(1);
    }
    return dateArray;
}


FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.