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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inputting current date from ASP page to Access - error

Status
Not open for further replies.

cdck

Programmer
Nov 25, 2003
281
US
I have a page that processes information from a form, then updates a row in an Access database by inserting the current date into one field.

My problem is that when I try to set that date value, it keeps coming up with a date and time (3/13/07 8:00:00 AM). I need to force it to be a short date (3/13/07).

I am setting the variable by stating

ReqByDate = Date

How should I be defining the variable so that it will only pass the month/day/year? Is there a format that I can use on Date?

Cheryl dc Kern
 
What is the datatype of the field where the date is inserted?

If it is a text field then you could use the FormatDateTime() function.

If it is a Date/Time field then you will always have the time in the field, even if it is always 12:00:00 AM
 
Actually, if your doing a SQL insert than you could use FormatDateTime and Access will still process it as a date (because your going to concatenate it into a string of values anyway).

The question I have is why is this a problem? If you only need a date in the output somewhere else, then use FormatDateTime there. In the meantime there are a number of advantages to knowing exactly what order records were inserted, or knowing the time of day. The database is going to store a time anyway, so you may as well store the current time. If you do decide to store midnight for every value, you can't go back. But if one day you decide storing the time is unnecessary, you can change all of the dates to midnight with a simple UPDATE function.

 
The Access field is Date/Time, set to short date.

When this date is pulled out of the database, it show a date in 1899 (I assume because of the time it was inserted).

When it is viewed in the database, it shows only the time. It seems as if ONLY the time is being input into the field, which makes not sense, but I can't seem to affect it.

So it's a problem because it doesn't work.

If I change the Access field to text, what should the code to set the variable look like? Should ReqBy = Date work? ALl I want is the date...

Cheryl dc Kern
 
why not just go into the access table and set the field default to now() and eliminate all that work?
 
Because this field is intended to show when the record was completed, not when it was started. The row is created when it starts, and this field should remain null until the user hits "complete" during the processing.

I found the problem - it was neither the table nor the format of the variable. It was missing quotes in the query inserting into the table. It threw no error, but was only inserting the time, not the date, into the table.

Thanks, everyone, for trying to help!

Cheryl dc Kern
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top