By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,310 Members | 1,466 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,310 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Jul 19 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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" <so*****@erols.com> wrote in message
news:1c**************************@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

Jul 19 '05 #2

P: n/a
"Phil Powell" <so*****@erols.com> wrote in message
news:1c**************************@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.


Hi Phil,

Try these articles:
http://www.aspfaq.com/show.asp?id=2023
http://www.aspfaq.com/show.asp?id=2040
http://www.aspfaq.com/show.asp?id=2260

Regards,
Peter Foti
Jul 19 '05 #3

P: n/a
I'm sorry but the articles you posted, albeit futuristically helpful,
just don't tell me how to insert a date, at least that makes sense to
me.

All I want to do is insert a date into a SQL Server datetime column,
nothing more, in fact, I want to insert the current date, which I assume
is the VBScript function Now(), if I'm correct..

would it not be:

"#" & Now() & "#"

or is it

"'" & Now() & "'"

Phil

---------------------------------------
TCL and PHP: The Superior Web Languages!
javascript: Is Cool
ASP: why?
http://valsignalandet.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #4

P: n/a
> "#" & Now() & "#"

or is it

"'" & Now() & "'"


Neither. If you do it this way, you rely on the web server's time being
correct, for starters, and also being in a format acceptable to SQL Server.
Did you see my other post?
Jul 19 '05 #5

P: n/a
The # signs are for Access, not SQL Server.

Now will give you datetime. Some of your post says you want the date only,
so you can strip out the time with DateValue:

dtEntryDateTime = Now()
dtEntryDate = DateValue(dtEntryDateTime)

Other than that, Aaron's post answered your question quite nicely

"The Nordic One" <de*********************@null.com> wrote in message
news:e5**************@TK2MSFTNGP09.phx.gbl...
I'm sorry but the articles you posted, albeit futuristically helpful,
just don't tell me how to insert a date, at least that makes sense to
me.

All I want to do is insert a date into a SQL Server datetime column,
nothing more, in fact, I want to insert the current date, which I assume
is the VBScript function Now(), if I'm correct..

would it not be:

"#" & Now() & "#"

or is it

"'" & Now() & "'"

Phil

---------------------------------------
TCL and PHP: The Superior Web Languages!
javascript: Is Cool
ASP: why?
http://valsignalandet.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #6

P: n/a
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

Jul 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.