Author |
Topic  |
StephenD
Senior Member
   
Australia
1044 Posts |
Posted - 29 May 2004 : 23:46:18
|
Snitz stores the date in the T_EVENT_DATE field in this format eg. 20040419000000 |
 |
|
The Impact
Junior Member
 
Australia
398 Posts |
Posted - 30 May 2004 : 00:14:57
|
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. |
 |
|
StephenD
Senior Member
   
Australia
1044 Posts |
Posted - 30 May 2004 : 01:06:18
|
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... |
 |
|
laser
Advanced Member
    
Australia
3859 Posts |
Posted - 30 May 2004 : 04:54:23
|
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. |
 |
|
laser
Advanced Member
    
Australia
3859 Posts |
Posted - 30 May 2004 : 09:07:09
|
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. |
 |
|
StephenD
Senior Member
   
Australia
1044 Posts |
Posted - 30 May 2004 : 18:46:29
|
Yes that works perfectly as you say. Will try and integrate your code now. Cheers. |
 |
|
StephenD
Senior Member
   
Australia
1044 Posts |
Posted - 30 May 2004 : 19:20:20
|
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. |
 |
|
StephenD
Senior Member
   
Australia
1044 Posts |
Posted - 30 May 2004 : 19:31:47
|
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 |
 |
|
laser
Advanced Member
    
Australia
3859 Posts |
Posted - 31 May 2004 : 06:02:51
|
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 |
 |
|
Topic  |
|