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
TJ_Tigger
05-21-2005, 10:16 AM
I believe that Worm has a datediff application or dll that he posted on the forums.
csd214
05-21-2005, 10:35 AM
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/showpost.php?p=36776&postcount=5
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.
TJ_Tigger
05-21-2005, 02:09 PM
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/showpost.php?p=44286&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
Thanx TJ, i'll simply use the Julian date format for calculation...
ledufe
08-18-2006, 11:28 PM
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....
sside
08-19-2006, 12:10 PM
...How do I count number of days between these two dates?...
You can visit my contribution here (http://www.indigorose.com/forums/showthread.php?t=16413) (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
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.