Date and Time in Hidden Value

Discussion in 'ASP General' started by Keith, Jul 6, 2004.

  1. Keith

    Keith Guest

    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
     
    Keith, Jul 6, 2004
    #1
    1. Advertising

  2. Keith wrote:
    > 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

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows [MVP], Jul 6, 2004
    #2
    1. Advertising

  3. > 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

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)
     
    Aaron [SQL Server MVP], Jul 6, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Berg
    Replies:
    0
    Views:
    797
    Chris Berg
    Oct 27, 2003
  2. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,285
    Michael Borgwardt
    May 30, 2004
  3. Keith Cochrane
    Replies:
    2
    Views:
    626
    Keith Cochrane
    Aug 6, 2006
  4. moonhk
    Replies:
    5
    Views:
    548
    moonhk
    Oct 11, 2006
  5. Rick
    Replies:
    3
    Views:
    8,213
    Alexey Smirnov
    Apr 13, 2010
Loading...

Share This Page