Date and Time in Hidden Value

K

Keith

How can I insert the current date and time into a hideen form field in a UK
format (dd/mm/yyy hh:mm:ss) that can be passed to a SQL DB?

I have been using <%=Date()%> as my hiddenn fields value, but this only
gives me the date, how can I modify this to give what I need?

Thanks
 
B

Bob Barrows [MVP]

Keith said:
How can I insert the current date and time into a hideen form field
in a UK format (dd/mm/yyy hh:mm:ss) that can be passed to a SQL DB?

I have been using <%=Date()%> as my hiddenn fields value, but this
only gives me the date, how can I modify this to give what I need?

Thanks

Dates are not stored with any format unless you store them in a character
column. See these articles:

http://www.aspfaq.com/show.asp?id=2040 help with dates
http://www.aspfaq.com/show.asp?id=2260 dd/mm/yyy confusion
http://www.aspfaq.com/show.asp?id=2313 vbscript

Also, look up an article in BOL (SQL Books Online) called "Using Date and
Time Data"


Bob Barrows
 
A

Aaron [SQL Server MVP]

How can I insert the current date and time into a hideen form field in a
UK
format (dd/mm/yyy hh:mm:ss) that can be passed to a SQL DB?

Why don't you let the database add the date and time? It is certainly smart
enough that it doesn't need to rely on ASP to tell it the current date and
time... and this will also reduce network chatter. Have a look at the
following in Query Analyzer:

SELECT GETDATE()
SELECT CURRENT_TIMESTAMP
SELECT {fn CURDATE()}

CREATE TABLE dbo.blat
(
id INT,
dt DATETIME NOT NULL DEFAULT GETDATE()
)
INSERT dbo.blat(id) SELECT 1
WAITFOR DELAY '00:00:01'
INSERT dbo.blat(id) SELECT 2

SELECT * FROM dbo.blat
DROP TABLE dbo.blat
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top