|
 |
asp_web_howto thread: how to store current date and time
Message #1 by "taherm@f... on Tue, 25 Sep 2001 10:00:34
|
|
i am using sql server and when ever an entry is made in my table i want to
have a field for date and time of the server. this will be used in my
orders table. when ever an order is placed it should store date and time
as well.
to achive the above i have a filed called orderdate in my table. but am
not sure of what datatype should i use and what formula shall is type so
that it stores the current date and time automatically
any suggestions plz help me..
thanks
Message #2 by Sam Clohesy <sam@e...> on Tue, 25 Sep 2001 10:11:26 +0100
|
|
Give the datetime field a default value of getdate()
-----Original Message-----
From: taherm@f...
[mailto:taherm@f...]
Sent: 25 September 2001 11:01
To: ASP Web HowTo
Subject: [asp_web_howto] how to store current date and time
i am using sql server and when ever an entry is made in my table i want to
have a field for date and time of the server. this will be used in my
orders table. when ever an order is placed it should store date and time
as well.
to achive the above i have a filed called orderdate in my table. but am
not sure of what datatype should i use and what formula shall is type so
that it stores the current date and time automatically
any suggestions plz help me..
thanks
Message #3 by "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> on Tue, 25 Sep 2001 10:44:21 +0100
|
|
set it to datetime format, and set the default value to be equal to
GETDATE()
-----Original Message-----
From: taherm@f...
[mailto:taherm@f...]
Sent: 25 September 2001 11:01
To: ASP Web HowTo
Subject: [asp_web_howto] how to store current date and time
i am using sql server and when ever an entry is made in my table i want to
have a field for date and time of the server. this will be used in my
orders table. when ever an order is placed it should store date and time
as well.
to achive the above i have a filed called orderdate in my table. but am
not sure of what datatype should i use and what formula shall is type so
that it stores the current date and time automatically
any suggestions plz help me..
thanks
Message #4 by "Drew, Ron" <RDrew@B...> on Tue, 25 Sep 2001 14:26:16 -0400
|
|
If Access...I use COMMAND to insert into my guestbook with parameters..here
is some of code (not all...just to give you an idea)...it works for me
Dim dtInput
dtInput = date
'current date time is last field...use ??? for parameters
objCommand.ActiveConnection = objConn
strSQL = "INSERT INTO Guestbook (Name, Email, City, St, Country, URL,
HowFind, Message, DateInput)" &_
" VALUES (?,?,?,?,?,?,?,?,?)"
objCommand.CommandText = strSQL
objCommand.Parameters.Append objCommand.CreateParameter("Name",200, ,30)
objCommand.Parameters.Append objCommand.CreateParameter("Email",200, ,40)
objCommand.Parameters.Append objCommand.CreateParameter("City",200, ,20)
objCommand.Parameters.Append objCommand.CreateParameter("St",200, ,2)
objCommand.Parameters.Append objCommand.CreateParameter("Country",200,
,20)
objCommand.Parameters.Append objCommand.CreateParameter("URL",200, ,40)
objCommand.Parameters.Append objCommand.CreateParameter("HowFind",200,
,45)
objCommand.Parameters.Append objCommand.CreateParameter("Message",200,
,180)
objCommand.Parameters.Append objCommand.CreateParameter("DateInput",134,
,10)
objCommand("Name") = sName
objCommand("Email") = sEmail
objCommand("City") = sCity
objCommand("St") = sSt
objCommand("Country") = sUSA
objCommand("URL") = sURL
objCommand("HowFind") = sHow
objCommand("Message") = sMessage
objCommand("DateInput") = dtInput
objCommand.Execute
-----Original Message-----
From: taherm@f... [mailto:taherm@f...]
Sent: Tuesday, September 25, 2001 6:01 AM
To: ASP Web HowTo
Subject: [asp_web_howto] how to store current date and time
i am using sql server and when ever an entry is made in my table i want to
have a field for date and time of the server. this will be used in my
orders table. when ever an order is placed it should store date and time
as well.
to achive the above i have a filed called orderdate in my table. but am
not sure of what datatype should i use and what formula shall is type so
that it stores the current date and time automatically
any suggestions plz help me..
thanks
Message #5 by info@e... on Thu, 27 Sep 2001 23:59:15
|
|
You can also accomplish this another way - easier for a beginner.
Make the datatype on your orderdate field in SQL varchar(so that it
can take anything). Then what you do is create a hidden field on your
html form with the current date value and insert it into the appropriate
field in your SQL server database.
Your form should like this:
<FORM name="anyName" method="post" action="">
<!-- NOte: The user cannot see or modify the hidden field -->
<INPUT type="hidden" name="anyName" value="<%
Response.Write now()%>">
<INPUT type="submit" name="btnName" value="Submit">
</FORM>
Note: The now() will insert the current date and time from your ASP
server. You can also replace that with date() for the date only or time()
for the time only.
On e-commerce applications, I usually put both of those into
seperate fields so that you can perform finds for either the date only
or the time only whenever you need it. It is just an extra feature.
I hope this helps!
Regards,
Elmer M.
> i am using sql server and when ever an entry is made in my table i
want to
> have a field for date and time of the server. this will be used in my
> orders table. when ever an order is placed it should store date and
time
> as well.
>
> to achive the above i have a filed called orderdate in my table. but
am
> not sure of what datatype should i use and what formula shall is
type so
> that it stores the current date and time automatically
>
> any suggestions plz help me..
> thanks
Message #6 by Greg Griffiths <griffiths@x...> on Sat, 29 Sep 2001 16:00:24 +0100
|
|
Alternatively, you could include it using SYSDATE or similar in your SQL query.
At 23:59 27/09/01 +0000, you wrote:
>You can also accomplish this another way - easier for a beginner.
>Make the datatype on your orderdate field in SQL varchar(so that it
>can take anything). Then what you do is create a hidden field on your
>html form with the current date value and insert it into the appropriate
>field in your SQL server database.
>
>Your form should like this:
>
><FORM name="anyName" method="post" action="">
>
><!-- NOte: The user cannot see or modify the hidden field -->
>
><INPUT type="hidden" name="anyName" value="<%
>Response.Write now()%>">
>
><INPUT type="submit" name="btnName" value="Submit">
>
></FORM>
>
>Note: The now() will insert the current date and time from your ASP
>server. You can also replace that with date() for the date only or time()
>for the time only.
>
>On e-commerce applications, I usually put both of those into
>seperate fields so that you can perform finds for either the date only
>or the time only whenever you need it. It is just an extra feature.
>
>I hope this helps!
>
>Regards,
>Elmer M.
>
>
> > i am using sql server and when ever an entry is made in my table i
>want to
> > have a field for date and time of the server. this will be used in my
> > orders table. when ever an order is placed it should store date and
>time
> > as well.
> >
> > to achive the above i have a filed called orderdate in my table. but
>am
> > not sure of what datatype should i use and what formula shall is
>type so
> > that it stores the current date and time automatically
> >
> > any suggestions plz help me..
> > thanks
>
|
|
 |