Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 8 of 8
  1. #1
    Join Date
    May 2005
    Posts
    1,115

    count number of days between two dates

    Hi guy, i need some help here... (my aplogies if this is a double post)

    Ok, I have two stings with two different dates stored in them;
    How do I count number of days between these two dates?

    Any built-in function?

    p.s.i think i misplaced this topic, if a moderator could move it to an appropicate location, it would be nice
    Last edited by bule; 05-21-2005 at 06:37 AM.

  2. #2
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    I believe that Worm has a datediff application or dll that he posted on the forums.
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  3. #3
    Join Date
    Oct 2001
    Location
    Norway
    Posts
    939
    Quote Originally Posted by TJ_Tigger
    I believe that Worm has a datediff application or dll that he posted on the forums.
    This one; I think
    http://www.indigorose.com/forums/sho...76&postcount=5

  4. #4
    Join Date
    May 2005
    Posts
    1,115
    Well, that is something similar to what I want, but since it's .dll, I don't know how it behaves...

    I returns the date difference, but I need it to return the amount of days.

  5. #5
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    Thanks csd214, that is the one I was thinking about. I forgot the context. Here is another post that should help.

    http://www.indigorose.com/forums/sho...86&postcount=2

    This project has a couple of functions in the application. You can convert from Julian to Gregorian and back.

    Take Date#1 and convert to Julian
    Take Date#2 and convert to Julian
    if Date#1 > Date#2 then
    Diff = Date#1 - Date#2
    else
    Diff = Date#2 - Date#1
    end
    dialog.message("diff", "The difference between the two dates is "..Diff);


    Or something along those lines

    Tigg
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  6. #6
    Join Date
    May 2005
    Posts
    1,115
    Thanx TJ, i'll simply use the Julian date format for calculation...

  7. #7
    Join Date
    Jul 2006
    Posts
    5
    hi guys!
    bule, and tj
    i guess this would help everyone else that would like to count the number of the days and the number of the weeks between two dates

    i used the code posted here and changed it a little, but it is working, im trying to learn lua and the autoplay, but i don´t have time to spare, but i talked with my boss and he showed some interest in buy this really good software, im using the pirated version of the autoplay 6 that a friend of mine presented to me as a software to make auto-run for CDs, but i've found this software much more useful than a simple auto-run maker...im using it and learning it until my company buy it(my boss said it will be on december when he will be travelling to usa in vacation), ans also im reading every post of this and other forums of auto-play or lua, and im making some preogress, and until i learn it im wish to help the others that have the same questions of me, so i will post not a project, but the code, to not encorage the piracy of any software...
    here is the code to a project with a calendar and some labels, and it show on selection the startdate of the selection.the end date of the selection, and calculate the number of the days and the number of weeks of the selection, i hope it helps, but i will fully understand if you guys erase this post, and i will come back to just "watch" the forum... so here is the code:

    on the global functions :
    -- the start date in julian
    function Gregorian2Julian_s(year_s, month_s, day_s)
    local UT=0
    local Y=year_s
    local D=day_s
    local M=month_s
    JD=367*Y-Math.Floor(7*(Y+Math.Floor((M+9)/12))/4)-Math.Floor(3*(Math.Floor((Y+(M-9)/7)/100)+1)/4)+Math.Floor(275*M/9)+D+1721028.5+UT/24
    return JD
    end
    -- the end date in julian
    function Gregorian2Julian_e(year_e, month_e, day_e)
    local UT=0
    local Y=year_e
    local D=day_e
    local M=month_e
    JD=367*Y-Math.Floor(7*(Y+Math.Floor((M+9)/12))/4)-Math.Floor(3*(Math.Floor((Y+(M-9)/7)/100)+1)/4)+Math.Floor(275*M/9)+D+1721028.5+UT/24
    return JD
    end


    ================================================== ====

    on the only page i have 9 objects:
    1 calendar
    8 labels

    the name of the labels are self explained just read the code.
    ================================================== ====
    on the OnSelect of the calendar goes this code

    -- Get the beginning and ending of the selection in the "Calendar1" calendar object.
    selection = Calendar.GetSelection("Calendar1");

    -- If a selection was made, display the dates in a dialog.
    -- If no selection is made, notify the user in a dialog.
    if (selection ~= nil) then
    Dialog.Message("Calendar Selection", "The beginning of the selection is: "..selection.Begin.."\r\nThe end of the selection is: "..selection.End, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    Label.SetText("_start_data_gregorian", e_StartDate)
    Label.SetText("_end_data_gregorian", e_EndDate)
    year_s = String.Left(e_StartDate, 4);
    day_s = String.Right(e_StartDate, 2);
    month_s = String.Mid(e_StartDate, 6, 2);
    sdate = day_s.."-"..month_s.."-"..year_s;
    Label.SetText("_start_data_gregorian-brazil", sdate);
    year_e = String.Left(e_EndDate, 4);
    day_e = String.Right(e_EndDate, 2);
    month_e = String.Mid(e_EndDate, 6, 2);
    edate = day_e.."-"..month_e.."-"..year_e;
    Label.SetText("_end_data_gregorian-brazil", edate);

    sjulianDate = Gregorian2Julian_s(year_s, month_s, day_s)

    Label.SetText("_start_data_julian", sjulianDate);

    ejulianDate = Gregorian2Julian_e(year_e, month_e, day_e)

    Label.SetText("_end_data_julian", ejulianDate);

    dif_days = (ejulianDate - sjulianDate)+1
    Label.SetText("_diff_days", dif_days);
    num_weeks = dif_days / 7
    Label.SetText("_num_weeks", num_weeks);

    else
    Dialog.Message("Notice", "There are no dates selected.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    end

    ================================================== ======

    ops, if you are going to remove this post, i guess i should tell that i've post another project inside the other post of the "setup factory forum" i was helping some guy to develop a software to make html signatures , i realy don´t know if that helps he or anybody else, but it is on this page
    http://www.indigorose.com/forums/showthread.php?t=16690

    i hope it helps
    sorry for may bad english im learning the language too....

  8. #8
    Join Date
    Dec 2003
    Location
    The Netherlands
    Posts
    475
    Quote Originally Posted by bule
    ...How do I count number of days between these two dates?...
    You can visit my contribution here (dt.dll).

    SubstractDateTime
    SubstractDateTimeEx
    will do exactly what you're asking.

    dateA = "11-07-1975 14:30:00";
    dateB = "19-08-2006 19:00:00";

    dateB - dateA

    will show: 11362.04:30:00 // days.hours.minutes.seconds

    You don't need to specify down to the seconds:

    dateA = "11-07-1975";
    dateB = "19-08-2006";

    dateB - dateA

    will show: 11362.00:00:00 // days.hours.minutes.seconds

    With Kind Regards

    sside

Similar Threads

  1. Setting my Application to Expire After Thirty Days
    By Desmond in forum AutoPlay Media Studio 5.0 Examples
    Replies: 0
    Last Post: 10-01-2003, 02:45 PM
  2. Prb with Count Delimited Strings
    By arnaud in forum AutoPlay Media Studio 4.0
    Replies: 4
    Last Post: 09-29-2003, 11:03 AM
  3. Can you assign the number of days a product will expire (i.e. 360 days)
    By jerilyn in forum AutoPlay Media Studio 4.0
    Replies: 2
    Last Post: 09-17-2003, 07:11 PM
  4. HOWTO: Limit the Number of Times an Install can be Run
    By Support in forum Setup Factory 6.0 Knowledge Base
    Replies: 0
    Last Post: 10-17-2002, 02:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts