Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting/Updating current date into SQL query 1

Status
Not open for further replies.

iao

Programmer
Feb 23, 2001
111
US
I am a new programmer. I have a simple question about databases and I apologize if this question is so basic, but I have been looking for quite a while and cannot find a straight answer on the web or in any of my books. All I am trying to do is to simply insert the computer's current date into an SQL query.

For example: I have a web form, where the users enter in a series of text boxes. I have a column in my database for the date. So, when the user types in his/her form and submits, I want to insert the current date (not time or seconds, just the date). The queries would go something like:

INSERT INTO TS.TP_SUBD(NAME, Address, Date)
VALUES('form.Name', 'form.Address', 'now')

UPDATE NAMETS
SET NAME = 'form.Name',
Address = 'form.Address',
Date = 'now'
WHERE NAMETS.Name = 'form.Name'

What I have for 'now' would be the current date, but that doesn't work. Any ideas on what I need to do? I feel a little sheepish asking but...
 
In Oracle SYSDATE is the current system date. Try using that, instead of 'now'
 
I tried that (that was actually my first try). I received an ORACLE error which said:

Oracle Error Code = 1858
ORA-01858: a non-numeric character was found where a numeric was expected

Any ideas on what I am doing wrong?
 
I just figured it out. I was putting in the '' and tried it without and using Sysdate.

It worked. Thanks so much for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top