Jump to content

BIRT Developer Center Download


Photo
- - - - -

Count dates <= today


  • Please log in to reply
3 replies to this topic

#1 perickles22

perickles22

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 08 August 2017 - 05:13 AM

Hello,

 

I am still a newb ;) but try my best improving my skills everyday.

 

Currently I am developing a report but having a problem getting the correct amnount of dates <= today.

 

I tried this without success.:

 

if (row["CORRECT_BY_DATE"] < BirtDateTime.day( (BirtDateTime.today()))
{
["CORRECT_BY_DATE"]
}

 

The format of "CORRECT_BY_DATE" is "DD.MM.YYYY 00:00:00".

 

Anybody who can help me?

 

 

Many thanks in advance,

 

Michael



#2 Chad M

Chad M

    Member

  • Members
  • PipPip
  • 24 posts

Posted 08 August 2017 - 08:22 AM

Hi Michael,

 

Is row["CORRECT_BY_DATE"] a string or a date object? If it is a date object, then try this:

var d = row["CORRECT_BY_DATE"];
if(d.getTime() < BirtDateTime.addDay(BirtDateTime.today(),1).getTime())
   d;

If it is not a date object, I would strongly recommend storing it as a date object, since that will allow you to work with it much easier. To convert it to a date object you need to parse the string like so:

//Assumes format is "DD.MM.YYYY hh:mm:ss"
var d = row["CORRECT_BY_DATE"];
var convertedDate = BirtDateTime.date(d.substr(6,4),d.substr(3,2)-1,d.substr(0,2),d.substr(11,2),d.substr(14,2),d.substr(17,2));

NOTE: 1 is subtracted from the month, since it is 0 indexed in the context of this function (e.g. 0 = Jan, 1 = Feb, etc).


Chad Montgomery

Customer Support Engineer  |  Customer Support

OpenText Corporation

 

 

 


#3 perickles22

perickles22

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 10 August 2017 - 03:53 AM

Hi Michael,

 

Is row["CORRECT_BY_DATE"] a string or a date object? If it is a date object, then try this:

var d = row["CORRECT_BY_DATE"];
if(d.getTime() < BirtDateTime.addDay(BirtDateTime.today(),1).getTime())
   d;

If it is not a date object, I would strongly recommend storing it as a date object, since that will allow you to work with it much easier. To convert it to a date object you need to parse the string like so:

//Assumes format is "DD.MM.YYYY hh:mm:ss"
var d = row["CORRECT_BY_DATE"];
var convertedDate = BirtDateTime.date(d.substr(6,4),d.substr(3,2)-1,d.substr(0,2),d.substr(11,2),d.substr(14,2),d.substr(17,2));

NOTE: 1 is subtracted from the month, since it is 0 indexed in the context of this function (e.g. 0 = Jan, 1 = Feb, etc).

 

Hello Chad,

 

many thanks for your reply.

So how to implement the second as yes thats the format. Shall I implement a new binding??

 

 

regards,

 

Michael



#4 perickles22

perickles22

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 10 August 2017 - 04:03 AM

Hello Chad,

 

many thanks for your reply.

So how to implement the second as yes thats the format. Shall I implement a new binding??

 

 

regards,

 

Michael