Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 10th, 2006, 03:48 PM
Authorized User
 
Join Date: Sep 2006
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to misskaos
Default Using "now()" to save date and time to database

Is there a way to keep the date and time from updating, using "now()?". I'm sure DateTime stamps would probably be more appropriate, but it seemed a lot "easier" to just use the now() function.

OOPS SORRY, THIS IS WHAT I'M TRYING TO DO:
I have a page that allows administrative users to create new forms.

Once the form is created, you can view all the forms located on the site.

If you click on a form that has been created, the administrator can view the information in that form and update any information in it.

Two types of administrators will be able to go in and make changes to the form. When certain information is completed and checked off on the form by the selected individuals a "COMPLETED" will appear next to the form. (i.e. when all SME's post required information for form, COMPLETED will appear on the right of the form link, under the column name/title "SME Input"... and the same would go for PM's.... "PM Input--COMPLETED". Well instead of COMPLETED, I want to post the date/time that each administrative type completed all necessary fields.

I have it working using the Now() function. However, it updates the time everytime I enter/exit the form (even if no changes are made).

Sorry it took me so long to explain myself, but I wanted to be sure everyone knew what I was trying to do.

Does anyone have any ideas of how I can "lock" the time once it has been entered into the database?

Here's what I have tried so far:

postModify.asp (snippet)
[..code..]
Dim CompletedDate
CompletedDate = now()

[..code..]
if (mEcpMV22PilotCostSubmit = "True" and mEcpMV22AircrewCostSubmit = "True" and mEcpMV22MaintenanceCostSubmit = "True" and mEcpCV22AircrewCostSubmit = "True" and mEcpCV22MaintenanceCostSubmit = "True" and mEcpCostSubmitEmail = "False") then
  If PMcomplete = "" then
  SMEcomplete = SMEcomplete
  PMcomplete = CompletedDate
  else
  PMcomplete = PMcomplete
 End if
  allComments = " Costing data for this ECP has been posted." & Chr(13)

[...code...]
 else
  PMcomplete = ""
end if
[...code...]

Thanks in advance for all your help.

Toni Burgess
misskaos99@yahoo.com
__________________
T.B.
misskaos99@yahoo.com
 
Old October 10th, 2006, 07:06 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Since I know your using a SQL back end, use getdatetime() in your sql statement so:

INSERT INTO table(date)VALUES(getdate())

That is sql's version of Now(), this way it should only update the database when you send a command to the database. Also, you say that the form updates every time someone enters and exits a form, have the database call attached to the form submit button. (the form action) so the only time the database can be update is when the Admin hits a button.

hth

--Stole this from a moderator

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
 
Old October 11th, 2006, 08:26 AM
Authorized User
 
Join Date: Sep 2006
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to misskaos
Default

I'm trying this now, thanks again!

Toni Burgess
misskaos99@yahoo.com
 
Old October 11th, 2006, 08:27 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

LOL, Ill add it to your tab, let me know how it works out.

--Stole this from a moderator

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
 
Old October 11th, 2006, 12:56 PM
Authorized User
 
Join Date: Sep 2006
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to misskaos
Default

Well, the GetDateTime() is not working. I searched everywhere online too and that was the only syntax I could find (not that I doubted u lol, just wanted to see if maybe I had/could do it another way ;) ). I think I get it figured with the now(). I just have to adjust my recordset.update so that it doesn't update the time everytime. Which of course if I'm setting the field to now() before the update then it's going to do it everytime. But if I put it afterwards, it won't update it at all. But I think I'll have it sooner or later. Soon as I think I need ya, I'll see if ya still around. Or I'll just ask u about it tonight on yahoo. But I have faith, and today I'm going to try to function as long as possible with just me and my reading material, my tab is getting kinda long lol jk lol :).

Thanks for all ya help. Talk to ya soon.

Toni Burgess
misskaos99@yahoo.com
 
Old October 11th, 2006, 01:11 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

LOL, i actually wrote the incorrect function, I originally wrote getdatetime(), that is not a valid sql function it is getdate(); I don't know why i wrote getdatetime and better yet why I didnt catch it before I posted it to the board. =\

Anyway I am around and yes your tab is getting kinda long!

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
 
Old October 11th, 2006, 01:26 PM
Authorized User
 
Join Date: Sep 2006
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to misskaos
Default

Really? that's how I'm finding it online "DateTime" hm, k lemme try that.

About my tab: it's a good thing you barter, i have a lot of "portions" to offer. lol

Toni Burgess
misskaos99@yahoo.com
 
Old October 11th, 2006, 02:00 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

DateTime is a type in SQL (like float, varchar, etc) getdate() is the function that returns the SQL Servers current date and time.

LOL @ bartering.

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
 
Old October 11th, 2006, 03:42 PM
Authorized User
 
Join Date: Sep 2006
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to misskaos
Default

lol yea I went back and saw it.. of course i slapped myself in the forehead, homer simpson style, like "duhhh" lol.

Just can't get the insert statement to work. The now of course works (just keeps updating). But the insert is not working at all. I think it's the function tho becuz if i just do a

recordset("fieldname") = now()
recordset.update
it will work

but if i try to put the insert statement there instead, i get nothing.


OK THIS IS HOW I CURRENTLY HAVE IT
Code:
if (mRS("ecpSubmitEmail") = True) and mRS("ecpSMEcomplete") = "" then
mRS.open "INSERT INTO ecpForms (ecpSMEcomplete) VALUES (getdate()) WHERE ID=" & decpID, mConnection
end if

if (mRS("ecpCostSubmitEmail") = True) and mRS("ecpPMcomplete") = "" then
mRS.open "INSERT INTO ecpForms (ecpPMcomplete) VALUES (getdate()) WHERE ID=" & decpID, mConnection
end if

mRS.update
mRS.Close

Response.Redirect("viewAll2.asp")
man i caught all kinds of errors!!
Toni Burgess
misskaos99@yahoo.com
 
Old October 11th, 2006, 03:55 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Your syntax is wrong. When you call INSERT, all sql does is add a new row to the table, you cant specify a WHERE clause. (Use where for select, delete, and update)

You syntax is this:

INSERT INTO ecpForms(ecpSMEcomplete) VALUES(getdate())

hth

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature





Similar Threads
Thread Thread Starter Forum Replies Last Post
date and time in EST time zone anboss XSLT 1 May 21st, 2008 01:42 PM
save time umeshtheone Pro VB 6 1 October 23rd, 2007 09:01 AM
sending date and time to access database Yasho VB.NET 2002/2003 Basics 3 May 24th, 2007 12:59 AM
You can't save this record at this time avd Access 4 June 12th, 2006 08:29 AM
insert system date. no date and time jimmy Access VBA 6 November 20th, 2003 01:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.