This topic is locked

Time Display and Refreshing Screen

2/27/2009 9:32:24 PM
ASPRunnerPro General questions
author

Hello everyone. I am not able to display time correctly in my ASP page created by ASPRunner. I have read the Time section for the visual editor and it appears very straight forward. My SQL DB has a time field that has 6 digits within it. If I read the instructions properly and it should work just right....but it does not.
My data shows "124500" that should display like "12:45:00". If I do not use the properties in the visual editor it displays "124500". If I set either the "view as" or "edit as" as time it shows the time like this: "124500:00:00 PM". What do I need to do to display properly?
Second question: Is there anyway to set a automatic refresh of the list screen? I want to update the list screen every 3 minutes.
Thank you for any assistance that is offered.
Sincerely,

Joe

R
Roger 2/27/2009

Hi Tman. A few quick things.
First of all your SQL DB datetime format has very little to do with vbscript (asprunner just uses it as a scripting environement).
Second, in order to dispay date and/or time properly, we need to understand how dates and/or times (datetime type columns) are stored in MS SQL, I'm guessing it's not Oracle or MySQL. It is essentially a propireiraty format that MS uses.
Also, what format are you using? For example: smalldatetime or datetime? It's not clear from your post.
So, we need to tell vbscript how to display what we want. Fortunately, we can extract dates, times and a plethora of other "DISPLAYED" or "CALCULABLE" results.
Try these in the display as for the datetime field:
FormatDateTime(now(),vbshorttime) - My guess is this is what you want.

FormatDateTime(now(),vblongtime)
Please note however, the way we display the date, time or datetime has nothing to do with the underlying format/storage method that any DB uses. It will remain the same, so as you are probably no doubt aware, displaying the information in a particular format will not change the underlyng data in the table.
In fact, if you do update a column in MS SQL (or Oracle/MySql) with a specific format of date (for example), the db ssytem will append (modify the data) with the representative value of the current time. For example you store 5/5/09 as the value for a datetime column at 01:30 (24 hour clock) then the system will store the data as 050520091300000 (5/5/2009 at 01:30:00:00) - the binary number is huge so I won't get into that. BTW:, this is just an example to help clarify.
Here are some links that may help:

http://www.devinfoware.com/Date-Time-Functions-VBScript.asp

http://www.w3schools.com/vbScript/func_formatdatetime.asp
Sorry for the long post, just trying to explain as much as possible to help clarify.
Hope this help.
Roger

1312 2/28/2009

Thank you for your input Roger.

The vendor for the SQL Server DB was not exactly consistent with norms. It had two fields, one for date, which appears to follow proper date practices, but stores the time in a seperate numeric field with HHMMSS, using a 24 hour clock format (by looking through the numbers it stores). With what you posed and the two links I have looked at, it appears that your correct that I would use the vbshorttime. I will see how it affects the output of the time data that is stored.
I will attempt to edit the page to display the proper time appearance. I am a newbie at this but I will give it a go.
Again thank you very much.

Joe

C
clig 3/2/2009

Second question: Is there anyway to set a automatic refresh of the list screen? I want to update the list screen every 3 minutes.

Thank you for any assistance that is offered.
Sincerely,

Joe


Something you could put in the lheader.htm template under layouts - you could even add a button for manual refresh as well...
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">

<META HTTP-EQUIV="Expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">

<META HTTP-EQUIV="Refresh" CONTENT="290">
***
<script language="JavaScript">

<!--

document.write('<font size=1 face=Tahoma color=Purple><b>Refreshed: ' + (new Date).toLocaleString() + '</b></font>');

//-->

</script>

&nbsp;&nbsp;|&nbsp;&nbsp;

<script>

function refresh()

{

window.location.reload();

}

</script>

<input type=button class="button" onclick='refresh();' value="Refresh">