473,394 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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
Jul 19 '05 #1
6 8360
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
"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
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
> "#" & 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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: georgios zakitraxis | last post by:
Hello out there in the jungle... =) I found out that i can calculate the dates e.g $today = strftime('%Y%m%d',mktime(0, 0, 0, date("m"), date("d"), date("Y"))); $yesterday =...
3
by: Astra | last post by:
Hi All Wonder if you can help me with the following calc, which I want to create to check whether or not a user has entered a valid credit card expiry date: 1) I have retrieve a value from 2 x...
7
by: Vinnie Davidson | last post by:
Hello! I'm trying to get all records from my SQL Server Database with "DeadlineDate" = today (not today - 24 hours). All records has a field called "DeadlineDate", and the date is stored in...
2
by: Richard | last post by:
I have a textbox and an HtmlInputButton control on a Webform for an Intranet app. When the user clicks the button, it is supposed to add today's date to the textbox using JavaScript on the client...
0
by: Rahul Chatterjee | last post by:
Hello All I have designed a dotnet application using VB which basically takes a selection and passes value to a crystal report which in turn passes the value to a Stored procedure. After the...
2
by: tshad | last post by:
I am trying to check the date of my field to check if it is greater that today, but I am getting an error. I am using : <asp:CompareValidator runat="server"...
4
by: Chris | last post by:
Hello, I am attempting to build a MS SQL query that will return data from "today"; today being current day 8:00AM-10:00PM today. My goal is to return the data from a table that is written to...
4
by: Kun | last post by:
i have a form which takes in inputs for a mysql query. one of the inputs is 'date'. normally, a user has to manually enter a date, but i am wondering if there is a way to create a button which...
7
nev
by: nev | last post by:
I use VB 2005 Pro v8.0.50727.42 I use datadesigner to manage my dataset. In my form, I dragged a datagridview of one of my tables. It has a date column. In the property pane for the date column,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.