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

  2. =?Utf-8?B?QmVydA==?=

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

  3. =?Utf-8?B?QmVydA==?=

    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. 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. srini
    Replies:
    9
    Views:
    11,743
    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:
    162
    mark | r
    Nov 30, 2005
  3. Brave
    Replies:
    3
    Views:
    892
    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:
    142
    Dr John Stockton
    Sep 26, 2004
  5. monk

    changing the date/time stamp

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

Share This Page