Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL TimeStamp

Status
Not open for further replies.

Creeder

Programmer
Jul 5, 2000
110
MY
Hi,

Basically all the data is Queried from a Sql database using stored procedure( retrieves ids,timestamp field,etc). Relevant information is then displayed on the form, ie textboxes and checkboxes. The user will make the changes and click submit which will call a SQL store procedure again.

However in the sp, one of the parameters field is a timestamp field. How do i actually store a timestamp field in ASP or pass the value?


 
Most SQL values like that come across as a String into ASP when you use a Recordset object. I'm pretty sure Timestamp works the same. To convert it to an ASP Date object, you'll have to format the string into a normal date string and use DateValue like so:

MyDate = DateValue("September 11, 1963")
or
MyDate = DateValue(SQLFormattedString) Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
Hi all,

For people with the same problem in the future with displaying SQL timestamp in ASP here is a code from the internet.

All work belong to the original writer.

function bin2str(Value)
dim Value16,ib,i
Value16="0x"
for i=1 to LenB(Value)
ib=hex(ascb(midb(value,i)))
if len(ib) < 2 then ib=&quot;0&quot;+ib
Value16=Value16+ib
next
bin2str=Value16
end function

*-- unfortunately i've lost the exact link to the website that has this function.

Check out :


 
TIMESTAMP and DATETIME are different data types in MS SQL Server. Applications never explicitly store values in a TIMESTAMP column and the values created by SQL Server are not related to dates at all, they are arbitrary sequence numbers.
Since one of the stored procedures has a parameter for the date and time of the transaction, this implies that the value will be stored in a column and the column datatype is probably DATETIME. MS SQL Server will convert strings into DATETIME values automatically if the string is in a format that it recognizes.

myTime = DateValue(&quot;10/07/01 3:23pm&quot;) will only yield the date part of the string, so if time is critical you best pass the string &quot;10/07/01 3:23pm&quot; .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top