Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Very easy?? How do I put today's date into SQL Server using ASP?

Reply
Thread Tools

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

 
 
Phil Powell
Guest
Posts: n/a
 
      02-16-2004
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
 
Reply With Quote
 
 
 
 
Aaron Bertrand - MVP
Guest
Posts: n/a
 
      02-16-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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



 
Reply With Quote
 
 
 
 
Julian Roberts
Guest
Posts: n/a
 
      02-17-2004
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





 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Re: java.sql.Date value truncated using JDBC in MS-SQL Server Lew Java 0 02-09-2007 01:21 AM
Need advice how to write a program to receive an image via email and put it into the SQL Server database Vanessa Lee Wireless Networking 0 02-19-2006 11:45 AM
How to read an SQL Server into a ASP page and then change, add, delete and write it back to SQL Server Belinda ASP General 4 06-11-2004 12:16 PM
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM



Advertisments