Web Development

Our forums are currently in maintenance mode and the ability to post is disabled. We will be back up and running as soon as possible. Thanks for your patience!

General discussion

Locked

What's the correct way to store a date??

By webmaster ·
I'm using a <FORM> to ask the user for a date. Like so...
<FORM Action="<% request.ServerVariables("SCRIPT_NAME") %>" METHOD="GET">
Date: <INPUT TYPE="text" NAME="ibuskey"><br>
<INPUT TYPE = "submit" NAME = "submit" VALUE = "write record">
</FORM>

Then i'm storing the date...
strIBUSKEY = "'" & Trim(Request.QueryString("ibuskey")) & "', "

When i attempt to write the above string into a record's date-field i get an error that i'm trying to write a string of text into a date-field.
Now, i'm new to VBScript (which is what i'm using to write my ASP's). So, obviously, i'm storing the date in an inappropriate variable type.

How should i be storing this date info?
--
webmaster@egoz.org

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

What's the correct way to store a date??

by mukul_gandhi In reply to What's the correct way to ...

You have to read date in asp as -
strIBUSKEY = Request.QueryString("ibuskey")
But u must make sure that date value is entered in html form in correct format. Input format of date will depend on the database ur using. e.g in Oracle, u must enter date by default as DD-MON-YYYY. If u choose some other input format, u have to convert the date input in asp appropriately e.g using to_date function in Oracle. You must give instruction in HTML page for the format u want in input.
Details for other databases are different. Check with them individually.

regards
-mukul

Collapse -

What's the correct way to store a date??

by webmaster In reply to What's the correct way to ...

Collapse -

What's the correct way to store a date??

by shadowtraitor In reply to What's the correct way to ...

hey
You should tell the users the format you want or gather the date string from seprate input boxes such a select combo box for the month, and 2 input boxes for the year and date.
Once you have the datestring you can convert it to be of datetime format using the Vbscript function call as follows
datestring = cdate(datestring)
in you SQL statement ensure that the you enclose the datestring with two pound signs(#) as in sample below
SQLSTRING = "INSERT INTO Timesheet (Date)values ("& datestring & "#)"
if you goto www.itknowledge.com you will find some good books on ASP and VB script.

Hope I helped

Collapse -

What's the correct way to store a date??

by webmaster In reply to What's the correct way to ...

Related Discussions

Related Forums