Very easy?? How do I put today's date into SQL Server using ASP?

Discussion in 'ASP General' started by Phil Powell, Feb 16, 2004.

  1. Phil Powell

    Phil Powell Guest

    The date field I believe is of type datetime, but I'm sorry I have
    absolutely no idea how to put today's date into a datetime column
    using ASP and SQL Server.

    Folks, I'm a LINUX guy!!! This is a project I have to get done today
    and that is about the only thing snagging it from being done before
    COB today.

    Please help.

    Thanx
    Phil
     
    Phil Powell, Feb 16, 2004
    #1
    1. Advertising

  2. If you want the date and time,

    INSERT table(column) VALUES(CURRENT_TIMESTAMP)

    If you just want the date:

    INSERT table(column) VALUES({fn CURDATE()})

    Better yet, make this the default for the table, then you don't even have to
    mention that table in the INSERT statement... try this out in query
    analyzer.

    CREATE TABLE blat
    (
    foo INT,
    bar SMALLDATETIME DEFAULT {fn CURDATE()},
    splunge DATETIME DEFAULT CURRENT_TIMESTAMP
    )
    INSERT blat(foo) VALUES(1)
    INSERT blat(foo) VALUES(2)
    SELECT foo, bar, splunge FROM blat
    DROP TABLE blat

    And for future db-related questions, please post to the asp.db group.

    --
    Aaron Bertrand
    SQL Server MVP
    http://www.aspfaq.com/




    "Phil Powell" <> wrote in message
    news:...
    > The date field I believe is of type datetime, but I'm sorry I have
    > absolutely no idea how to put today's date into a datetime column
    > using ASP and SQL Server.
    >
    > Folks, I'm a LINUX guy!!! This is a project I have to get done today
    > and that is about the only thing snagging it from being done before
    > COB today.
    >
    > Please help.
    >
    > Thanx
    > Phil
     
    Aaron Bertrand - MVP, Feb 16, 2004
    #2
    1. Advertising

  3. You could give the field a default value of getdate() in the db.

    --
    Jules
    http://www.charon.co.uk/charoncart
    Charon Cart 3
    Shopping Cart Extension for Dreamweaver MX/MX 2004
     
    Julian Roberts, Feb 17, 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. TB
    Replies:
    0
    Views:
    453
  2. Pasquale

    Put the date of today in a text control

    Pasquale, Feb 11, 2007, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    98
    Stefan Kalcher
    Feb 12, 2007
  3. Vinnie Davidson

    ASP Date: get records with date = today (SQL Server)

    Vinnie Davidson, Aug 13, 2005, in forum: ASP General
    Replies:
    6
    Views:
    326
    Aaron Bertrand [SQL Server MVP]
    Aug 15, 2005
  4. Ron
    Replies:
    12
    Views:
    420
    Gunnar Hjalmarsson
    Jul 22, 2003
  5. joeyej
    Replies:
    7
    Views:
    149
    Randy Webb
    Apr 6, 2006
Loading...

Share This Page