Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP General (http://www.velocityreviews.com/forums/f65-asp-general.html)
-   -   Very easy?? How do I put today's date into SQL Server using ASP? (http://www.velocityreviews.com/forums/t793378-very-easy-how-do-i-put-todays-date-into-sql-server-using-asp.html)

Phil Powell 02-16-2004 09:11 PM

Very easy?? How do I put today's date into SQL Server using ASP?
 
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 02-16-2004 09:23 PM

Re: Very easy?? How do I put today's date into SQL Server using ASP?
 
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" <soazine@erols.com> wrote in message
news:1cdca2a7.0402161311.52524917@posting.google.c 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




Julian Roberts 02-17-2004 12:04 AM

Re: Very easy?? How do I put today's date into SQL Server using ASP?
 
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







All times are GMT. The time now is 09:27 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57