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

P

Phil Powell

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
 
A

Aaron Bertrand - MVP

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,188
Latest member
Crypto TaxSoftware

Latest Threads

Top