Date/Time stamp in SQL

Discussion in 'ASP .Net' started by =?Utf-8?B?QmVydA==?=, Jan 30, 2004.

  1. I would like to store a Date/Time stamp in a SQL tabel
    Now only the Date is stred and not the time. How to I get the time also

    This is the code (There is more, but that works)

    atSQLexe ex=new atSQLexe()
    ex.addConnection=app.dbConnection
    sql="INSERT INTO Log (UserID, Date) VALUES (@UserID, @Date)"
    ex.addParm("@UserID",userID)
    ex.addParm("@Date", DateTime.Today)
    tr

    ex.ExecuteSQL(sql)
    }
     
    =?Utf-8?B?QmVydA==?=, Jan 30, 2004
    #1
    1. Advertisements

  2. Kim Larsen

    Kim Larsen Guest

    Try using

    DateTime.Now insted of DateTime.Today

    /Kim


    "Bert" <> skrev i en meddelelse
    news:...
    > I would like to store a Date/Time stamp in a SQL tabel.
    > Now only the Date is stred and not the time. How to I get the time also?
    >
    > This is the code (There is more, but that works):
    >
    > atSQLexe ex=new atSQLexe();
    > ex.addConnection=app.dbConnection;
    > sql="INSERT INTO Log (UserID, Date) VALUES (@UserID, @Date)";
    > ex.addParm("@UserID",userID);
    > ex.addParm("@Date", DateTime.Today);
    > try
    > {
    > ex.ExecuteSQL(sql);
    > }
     
    Kim Larsen, Jan 30, 2004
    #2
    1. Advertisements

  3. Wardeaux

    Wardeaux Guest

    Bert,
    if you have access to the table field definitions, you can set the default
    value of the desired field to "getdate()", this retrieves the date/time on
    the SQL server automatically, no need to specify manually...
    hope this helps...
    wardeaux

    "Bert" <> wrote in message
    news:...
    > I would like to store a Date/Time stamp in a SQL tabel.
    > Now only the Date is stred and not the time. How to I get the time also?
    >
    > This is the code (There is more, but that works):
    >
    > atSQLexe ex=new atSQLexe();
    > ex.addConnection=app.dbConnection;
    > sql="INSERT INTO Log (UserID, Date) VALUES (@UserID, @Date)";
    > ex.addParm("@UserID",userID);
    > ex.addParm("@Date", DateTime.Today);
    > try
    > {
    > ex.ExecuteSQL(sql);
    > }
     
    Wardeaux, Jan 30, 2004
    #3
    1. Advertisements

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. srini
    Replies:
    9
    Views:
    12,218
    Beauregard T. Shagnasty
    Apr 14, 2004
  2. mark | r

    time and date stamp - start stop button?

    mark | r, Nov 30, 2005, in forum: ASP General
    Replies:
    3
    Views:
    231
    mark | r
    Nov 30, 2005
  3. Brave
    Replies:
    3
    Views:
    1,037
    Brave
    Jul 25, 2009
  4. Dr John Stockton

    Appending Date/Time Stamp to filename

    Dr John Stockton, Sep 26, 2004, in forum: Javascript
    Replies:
    0
    Views:
    233
    Dr John Stockton
    Sep 26, 2004
  5. monk

    changing the date/time stamp

    monk, Feb 26, 2008, in forum: Perl Misc
    Replies:
    3
    Views:
    172
    Tad J McClellan
    Feb 27, 2008
Loading...

Share This Page