Source language: Translate to:

Time/Date difference

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Time/Date difference

Postby Alex » Tue Oct 25, 2011 1:16 am

Hi,

I am lost, because I have 2 dates with hours in a text file:

21/10/2011;15:40

24/10/2011;13:10

the interval is every 5 min. How can I do to write in the text file the old dates and times with the 5min interval?

For example, this will be:

21/10/2011;15:40
21/10/2011;15:45
21/10/2011;15:50
21/10/2011;15:55
...
24/10/2011;13:05
24/10/2011;13:10

Thanks


Alex
Alex
 
Posts: 745
Joined: Sat Mar 04, 2006 4:53 am

Postby smartmedia » Tue Oct 25, 2011 3:50 am

Hi..

Download and try the demo pub.
http://dl.dropbox.com/u/8766047/NB/CompareDateTime.pub
User avatar
smartmedia
 
Posts: 889
Joined: Fri Apr 01, 2005 6:50 am
Location: Hellas

Postby Alex » Tue Oct 25, 2011 4:09 am

Hi smartmedia,

Thanks, but I don't understand, this only compare 2 dates.
What I am trying to do is to complete info between 2 dates and 2 hours, like this example:

I have:
START
21/10/2011;15:40
END
24/10/2011;13:10

With an interval of 5 min.

So the result will be:

21/10/2011;15:40
21/10/2011;15:45
21/10/2011;15:50
21/10/2011;15:55
...
24/10/2011;13:05
24/10/2011;13:10

Thanks


Alex
Alex
 
Posts: 745
Joined: Sat Mar 04, 2006 4:53 am

Postby smartmedia » Tue Oct 25, 2011 4:14 am

Hi..
Thanks, but I don't understand, this only compare 2 dates.
What I am trying to do is to complete info between 2 dates and 2 hours, like this example:


Please download again the example and check the code. This checks both date and time to see if first string is older than second.
User avatar
smartmedia
 
Posts: 889
Joined: Fri Apr 01, 2005 6:50 am
Location: Hellas

Postby Alex » Tue Oct 25, 2011 4:29 am

Hi,

Yes, I know, but this don't tell me how can I do to add every time +5 min and that it automaticaly change date and hour.
If I am at 14:55 and I add +5 min then it will be 14:60 and if I am the 22/10/2011 and I add +5min at 23:55, how will it automaticaly change the date and time to be the 23/10/2011 and 00:00?

Thanks


Alex
Alex
 
Posts: 745
Joined: Sat Mar 04, 2006 4:53 am

Postby Apoleo » Tue Oct 25, 2011 5:43 am

You can do it easily with a JScript or VBScript function. I did the JScript one.

Code: Select all
{NeoBook Function}
Version=5,70
Language=JScript
Param=[%1]|Text|Date (dd/mm/yyyy;hh:mm)
Param=[%2]|Number|Minutes Next
Param=[%3]|Variable|Return
{End}
//24/10/2011;13:10
var MinMilli = 1000 * 60;
function nextDate(date, mins) {
    var dmy = date.substr(0,date.indexOf(";")).split("/");
    var hm = date.substr(date.indexOf(";")+1).split(":");
    var d = new Date(dmy[2],dmy[1]-1,dmy[0],hm[0],hm[1]);
    var ltime = d.getTime() + (mins * MinMilli);
    d.setTime(ltime);
    return d.getDate()+"/"+(d.getMonth()+1)+"/"+d.getFullYear()+";" + d.getHours()+":" + (d.getMinutes()<10?"0":"")+d.getMinutes();
}
nbSetVar("[%3]", nextDate('[%1]', [%2]));


Saludos
Last edited by Apoleo on Tue Oct 25, 2011 5:52 am, edited 1 time in total.
User avatar
Apoleo
 
Posts: 88
Joined: Sat May 14, 2005 1:17 pm
Location: Sevilla, España

Postby Alex » Tue Oct 25, 2011 5:48 am

Hi Apoleo,

Thanks, it is exactly what I was searching for.

Thansk


Alex
Alex
 
Posts: 745
Joined: Sat Mar 04, 2006 4:53 am


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 2 guests