# date field from a form



## emagdnim (Jun 21, 2004)

ok i have no idea how to get a date into a database when a form is submitted. I am using an Access 97 db, I have the date field set to date/time and I'm assuming im right in that when I set up the insert form behavior I set the the whatever form field I have for date to date ms access instead of just date, but I could, ofcourse, be wrong. I aslo want it so that the user does not enter the date (for obvious reasons), but for it to just populate the field in access when the form is submitted. I've tried setting a fields value to <%=date()%> but that didn't work. I am now clueless. HELP
also i am using dreamweaver, asp, vbscript


----------



## Squashman (Apr 4, 2003)

Isn't is just <%=Date%>


----------



## emagdnim (Jun 21, 2004)

ok i tried that too and it didnt work. Here is what my code looks like:


*Date:*<%=date()%> ">*Location:*<%Response.Write strLocation%> "> 
*Item:*<%Response.Write strItem%> "> 
*Starting Inventory:*<%Response.Write strStartInv%> "> 
*Items Sold:*<%Response.Write strSold%> "> 
*Adjustments:*<%Response.Write strAdj%> "> 
*Adjustments Memo:*<%Response.Write strAdjMemo%> "> 
*Adjusted By:*<%Response.Write strAdjBy%> "> 
*Ending Inventory:*<%Response.Write strEndInv%> "> 


<%
Dim strLocation, strItem, strStartInv, strSold, strAdj, strAdjMemo, strAdjBy, strEndInv
strLocation = Request.Form("location")
strItem = Request.Form("item")
strStartInv = Request.Form("startinv")
strSold = Request.Form("sold")
strAdj = Request.Form("adj")	
strAdjMemo = Request.Form("adjmemo")
strAdjBy = Request.Form("adjby")
strEndInv = Request.Form("endinv")
%>

where they are all requested form the previous page where the form actually resisded. As ive said before this is a confirmation page so a user can make sure they entered the right information


----------



## Rockn (Jul 29, 2001)

Add the lines in red:


*Date:*<%=date()%> [/COLOR]">*Location:*<%Response.Write strLocation%> "> 
*Item:*<%Response.Write strItem%> "> 
*Starting Inventory:*<%Response.Write strStartInv%> "> 
*Items Sold:*<%Response.Write strSold%> "> 
*Adjustments:*<%Response.Write strAdj%> "> 
*Adjustments Memo:*<%Response.Write strAdjMemo%> "> 
*Adjusted By:*<%Response.Write strAdjBy%> "> 
*Ending Inventory:*<%Response.Write strEndInv%> "> 


<%
Dim strLocation, strItem, strStartInv, strSold, strAdj, strAdjMemo, strAdjBy, strEndInv
strLocation = Request.Form("location")
strDate = Date()

strItem = Request.Form("item")
strStartInv = Request.Form("startinv")
strSold = Request.Form("sold")
strAdj = Request.Form("adj") 
strAdjMemo = Request.Form("adjmemo")
strAdjBy = Request.Form("adjby")
strEndInv = Request.Form("endinv")
%>

where they are all requested form the previous page where the form actually resisded. As ive said before this is a confirmation page so a user can make sure they entered the right information


----------



## emagdnim (Jun 21, 2004)

damn i cant believe that, thanks dude


----------



## emagdnim (Jun 21, 2004)

ok i did what you had in red plus declared it in the dim as strDate and now its not working at all again, is it something on teh back end in the database?


----------



## emagdnim (Jun 21, 2004)

could it be that when you use strDate = date() it comes out as 7/8/2004 but in the database it gets displayed as 07/08/2004?

could it have to do with the input mask or display in the database? Also, some have said since i am declaring it as a string i should use # symbols but I have no idea where to put those


----------



## Rockn (Jul 29, 2001)

Only if you do not have the field in the table designated as a date/time fieild or have specified some sort of date format. It should work


----------



## emagdnim (Jun 21, 2004)

ok lets review, i have the following code:
Dim strDate
strDate = date()
hiddenfield value = <%=strDate%>

In the database I have a date field set up as date/time, its display is as general time, and I do not have an input mask right now but i did have ##/##/#### and #/#/####

In the insert function in dreamweaver I have date inserts into Date as Date and Ive tried date inserts into Date as Date ms access. The only time I can get the insert function to work is when I just ignore the date all together but that is not an option. So the problem has to have something to do with the date becuase it works otherwise. Can anyone think of anything else?

ok so a guy on the dreamweaver help forum site said that if the date is being done automatically I don't even have to worry about inserting it from a hidden field at all. He said I dont even need a form for the date. He said to set the "default value" of my date field in the database to either date() or now() depending on my deisred results. Does anyone now exaclty where I would put either of those functions


----------



## emagdnim (Jun 21, 2004)

thanks guys I got it all figured out


----------



## Squashman (Apr 4, 2003)

emagdnim said:


> thanks guys I got it all figured out


And your solution was......?


----------



## emagdnim (Jun 21, 2004)

for the date i just had the database handle it, i put the date() function as the default value in the database, MUCH easier, damn im a noob.


----------

