Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/O Code)
 Calculating 'days since' or 'days to go'
 New Topic  Topic Locked
 Printer Friendly
Previous Page
Author Previous Topic Topic Next Topic
Page: of 2

StephenD
Senior Member

Australia
1044 Posts

Posted - 29 May 2004 :  23:46:18  Show Profile  Send StephenD a Yahoo! Message
Snitz stores the date in the T_EVENT_DATE field in this format eg. 20040419000000
Go to Top of Page

The Impact
Junior Member

Australia
398 Posts

Posted - 30 May 2004 :  00:14:57  Show Profile
quote:
Actually it works for Status_date = #15/03/2004# too.
There is no 15th month so it reconises it as a DD/MM date.

I always put the month first though, it eliminates problems when you have dates like 3/5/2004. Is it March or May ?

Take a look in the inc_func_common.asp file, all the date functions are included in there and make a special note of chkDate.
Go to Top of Page

StephenD
Senior Member

Australia
1044 Posts

Posted - 30 May 2004 :  01:06:18  Show Profile  Send StephenD a Yahoo! Message
This is the closest I've been able to get it using the dates pulled from the DB:
19 Apr 2004

Microsoft VBScript runtime error '800a000d'

Type mismatch: '[string: "19/04/2004"]'

/hl_equipment3.asp, line 346

This is the code as it stands now:
Response.Write	"                <td bgcolor=""" & strForumCellColor & """ valign=""middle"" align=""center""> <font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" &  strForumFontColor & """>" & chkDate(Status_Date, vbLongDate, false) & "<br />" & vbNewline
		        						
minutesTotal = FormatDateTime(chkDate(Status_date, vbLongDate, false)) - (Now()+STRTIMEADJUST/24) * 24 * 60
hoursTotal = int(minutesTotal / 60)
daysSince = int(hoursTotal / 24)
hoursSince = hoursTotal mod 24
minutesSince = minutestotal mod 60
if daysSince = 0 then Response.Write "<font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """ color=""" &  strForumFontColor & """>" & " today " & "</font></td>"
if daysSince = -1 then Response.Write daysSince & "<font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """ color=""" &  strForumFontColor & """>" & " day ago " & "</font></td>"
if daysSince < -1 then Response.Write daysSince & "<font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """ color=""green"">" & " days ago " & "</font></td>"


Any other clues...
Go to Top of Page

laser
Advanced Member

Australia
3859 Posts

Posted - 30 May 2004 :  04:54:23  Show Profile
Which line is line 346 though ?

I'm guessing the "minutesTotal = ..." line

minutesTotal should be a number in the end, it seems that the FormatDateTime is screwing things up.
Go to Top of Page

laser
Advanced Member

Australia
3859 Posts

Posted - 30 May 2004 :  09:07:09  Show Profile
Try this ....


<!--#include virtual="snitz3403/inc_func_common.asp"-->
<%
STRTIMEADJUST = 14
Status_date = "20040530231000"

Status_date = CDate(FormatDateTime(chkDate(Status_date, " ", true)))
Response.Write "<br />Status Date : " & Status_Date
Response.Write "<br />Currently : " & Now()+STRTIMEADJUST/24
minutesTotal = (Status_date - (Now()+STRTIMEADJUST/24)) * 24 * 60

If minutesTotal > 0 then
	Response.WRite "<br />Mins : " & minutesTotal & "<br />"
	
	hoursTotal = int(minutesTotal / 60)
	daysSince = int(hoursTotal / 24)
	hoursSince = hoursTotal mod 24
	minutesSince = minutestotal mod 60
	if daysSince = 1 then Response.Write daysSince & " day, "
	if daysSince > 1 then Response.Write daysSince & " days, "
	if hoursSince = 1 then Response.Write hoursSince & " hour,"  
	if hoursSince > 1 then Response.Write hoursSince & " hours, "
	Response.Write minutesSince & " minutes to go"
Else
	minutesTotal = ((Now()+STRTIMEADJUST/24)-Status_date) * 24 * 60

	Response.WRite "<br />Mins : " & minutesTotal & "<br />"
	
	hoursTotal = int(minutesTotal / 60)
	daysSince = int(hoursTotal / 24)
	hoursSince = hoursTotal mod 24
	minutesSince = minutestotal mod 60
	if daysSince = 1 then Response.Write daysSince & " day, "
	if daysSince > 1 then Response.Write daysSince & " days, "
	if hoursSince = 1 then Response.Write hoursSince & " hour,"  
	if hoursSince > 1 then Response.Write hoursSince & " hours, "

	Response.Write minutesSince & " minutes since that date"
End If 
%>

You will need to change Line 1 (where your Snitz install is) and Line 3 (the diff between your timezone and the servers timezone), but the rest works perfectly .. just paste that into a new file upload.
Go to Top of Page

StephenD
Senior Member

Australia
1044 Posts

Posted - 30 May 2004 :  18:46:29  Show Profile  Send StephenD a Yahoo! Message
Yes that works perfectly as you say. Will try and integrate your code now. Cheers.
Go to Top of Page

StephenD
Senior Member

Australia
1044 Posts

Posted - 30 May 2004 :  19:20:20  Show Profile  Send StephenD a Yahoo! Message
Got it thanks Laser.
If Status_date = "" then
		        Response.Write	"                <td bgcolor=""" & strForumCellColor & """ valign=""middle"" align=""center""> <font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" &  strForumFontColor & """>" & chkDate(Status_Date, vbLongDate, false) & "<br />" & vbNewline
                   else
			Response.Write	"                <td bgcolor=""" & strForumCellColor & """ valign=""middle"" align=""center""> <font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" &  strForumFontColor & """>" & chkDate(Status_Date, vbLongDate, false) & "<br />" & vbNewline		        						
Display_date = CDate(FormatDateTime(chkDate(Status_date, " ", true)))
minutesTotal = (Display_date - (Now()+STRTIMEADJUST/24)) * 24 * 60
hoursTotal = int(minutesTotal / 60)
daysSince = int(hoursTotal / 24)
hoursSince = hoursTotal mod 24
minutesSince = minutestotal mod 60
if daysSince = 0 then Response.Write "<font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """ color=""" &  strForumFontColor & """>" & " today " & "</font></td>"
if daysSince = -1 then Response.Write daysSince & "<font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """ color=""" &  strForumFontColor & """>" & " day ago " & "</font></td>"
if daysSince < -1 then Response.Write daysSince & "<font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """ color=""green"">" & " days ago " & "</font></td>"
end if


Just need to colour code it a bit better ie < 14 days green, >14 days red etc. Otherwise perfect! Once again, thank you for your patience and help.
Go to Top of Page

StephenD
Senior Member

Australia
1044 Posts

Posted - 30 May 2004 :  19:31:47  Show Profile  Send StephenD a Yahoo! Message
Done, got rid of the -ve sign in front of the number too:
If Status_date = "" then
		        Response.Write	"                <td bgcolor=""" & strForumCellColor & """ valign=""middle"" align=""center""> <font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" &  strForumFontColor & """>" & chkDate(Status_Date, vbLongDate, false) & "<br />" & vbNewline
                   else
			Response.Write	"                <td bgcolor=""" & strForumCellColor & """ valign=""middle"" align=""center""> <font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" &  strForumFontColor & """>" & chkDate(Status_Date, vbLongDate, false) & "<br />" & vbNewline		        						
Display_date = CDate(FormatDateTime(chkDate(Status_date, " ", true)))
minutesTotal = (Display_date - (Now()+STRTIMEADJUST/24)) * 24 * 60 *-1
hoursTotal = int(minutesTotal / 60)
daysSince = int(hoursTotal / 24)
hoursSince = hoursTotal mod 24
minutesSince = minutestotal mod 60
if daysSince = 0 then Response.Write "<font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """ color=""" &  strForumFontColor & """>" & " today " & "</font></td>"
if daysSince = 1 then Response.Write daysSince & "<font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """ color=""" &  strForumFontColor & """>" & " day ago " & "</font></td>"
if daysSince <15 then Response.Write daysSince & "<font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """ color=""green"">" & " days ago " & "</font></td>"
if daysSince >15 then Response.Write daysSince & "<font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """ color=""red"">" & " days ago " & "</font></td>"
end if
Go to Top of Page

laser
Advanced Member

Australia
3859 Posts

Posted - 31 May 2004 :  06:02:51  Show Profile
quote:
Once again, thank you for your patience and help.
np's mate, glad to help where I can. Although it took me a while to get it working with the Snitz format
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Previous Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.96 seconds. Powered By: Snitz Forums 2000 Version 3.4.07