|
 |
asp_databases thread: Oracle and Date Formatting
Message #1 by "Snyder, Jason" <Jason.Snyder@t...> on Thu, 21 Nov 2002 13:12:10 -0800
|
|
Hi,
[Task]
One of the things that I am trying to do is to search on dates in an Oracle 9i database through ASP and SQL. So far I have been
able to do it if the customer types in the date in the DD-MMM-YY format which is native to Oracle.
[Main Problem]
The problem is that this format is different from what they are used to using and the customers will probably see my scripts as
broken and complain and stop using my stuff if they suddenly have to enter things into the DD-MMM-YY (or DD-MMM-YYYY) format with no
other options even if I add comments to tell them how to enter it in.
[Why I ask here]
I have been looking for functions in both ASP and Oracle land for something that will fill the job, but I haven't seen anything that
does what I need so far. (Probably overlooking something.) Most of what I have seen so far is either formatting output or doing
type conversions that will not help.
[What I need]
I use the VBScript IsDate() function to validate that the user has entered in a valid date of their choice, now I need to be able to
convert any string that they entered that passes the IsDate() function into the DD-MMM-YYYY format. (It would be nice to convert
into any format that I want as long as the output is a string.) Any suggestions?
--Jason Snyder--
Message #2 by Greg Griffiths <greg2@s...> on Fri, 22 Nov 2002 19:52:54 +0000
|
|
Many of us use the to_date and the to_char functions without an issue, why
can't you use them ?
At 13:12 21/11/02 -0800, you wrote:
>Hi,
>[Task]
>One of the things that I am trying to do is to search on dates in an
>Oracle 9i database through ASP and SQL. So far I have been able to do it
>if the customer types in the date in the DD-MMM-YY format which is native
>to Oracle.
>
>[Main Problem]
>The problem is that this format is different from what they are used to
>using and the customers will probably see my scripts as broken and
>complain and stop using my stuff if they suddenly have to enter things
>into the DD-MMM-YY (or DD-MMM-YYYY) format with no other options even if I
>add comments to tell them how to enter it in.
>
>[Why I ask here]
>I have been looking for functions in both ASP and Oracle land for
>something that will fill the job, but I haven't seen anything that does
>what I need so far. (Probably overlooking something.) Most of what I
>have seen so far is either formatting output or doing type conversions
>that will not help.
>
>[What I need]
>I use the VBScript IsDate() function to validate that the user has entered
>in a valid date of their choice, now I need to be able to convert any
>string that they entered that passes the IsDate() function into the
>DD-MMM-YYYY format. (It would be nice to convert into any format that I
>want as long as the output is a string.) Any suggestions?
>
>--Jason Snyder--
>
>
Message #3 by "Peter Foti (PeterF)" <PeterF@S...> on Fri, 22 Nov 2002 15:34:35 -0500
|
|
Another option would be for you to force the user to select the date values
instead of typing it. For example:
<select name="Year" id="Year">
<option value="1974">1974</option>
...
<option value="2002">2002</option>
</select>
<select name="Month" id="Month">
<option value="01">Jan</option>
<option value="02">Feb</option>
...
<option value="12">Dec</option>
</select>
<select name="Day" id="Day">
<option value="01">1</option>
<option value="02">2</option>
...
<option value="31">31</option>
</select>
Of course, this does not ensure a valid date. For example, the user could
enter Feb. 31 (an invalid date). You could add some Javascript to
dynamically fill in the contents of the Day select box by examining the year
and month (the year is only needed if the month is Feb, for determining if
there are 28 or 29 days).
Anyway, once the data is submitted, you can manipulate it into any format
you like.
Just an idea.
Regards,
Peter Foti
-----Original Message-----
From: Greg Griffiths [mailto:greg2@s...]
Sent: Friday, November 22, 2002 2:53 PM
To: ASP Databases
Subject: [asp_databases] Re: Oracle and Date Formatting
Many of us use the to_date and the to_char functions without an
issue, why
can't you use them ?
At 13:12 21/11/02 -0800, you wrote:
>Hi,
>[Task]
>One of the things that I am trying to do is to search on dates in an
>Oracle 9i database through ASP and SQL. So far I have been
able to do it
>if the customer types in the date in the DD-MMM-YY format
which is native
>to Oracle.
>
>[Main Problem]
>The problem is that this format is different from what they
are used to
>using and the customers will probably see my scripts as broken and
>complain and stop using my stuff if they suddenly have to enter things
>into the DD-MMM-YY (or DD-MMM-YYYY) format with no other
options even if I
>add comments to tell them how to enter it in.
>
>[Why I ask here]
>I have been looking for functions in both ASP and Oracle land for
>something that will fill the job, but I haven't seen anything
that does
>what I need so far. (Probably overlooking something.) Most of what I
>have seen so far is either formatting output or doing type conversions
>that will not help.
>
>[What I need]
>I use the VBScript IsDate() function to validate that the user
has entered
>in a valid date of their choice, now I need to be able to convert any
>string that they entered that passes the IsDate() function into the
>DD-MMM-YYYY format. (It would be nice to convert into any
format that I
>want as long as the output is a string.) Any suggestions?
>
>--Jason Snyder--
>
>
|
|
 |