Date Problem!

Results 1 to 5 of 5

Thread: Date Problem!

  1. #1
    Rupali Guest

    Default Date Problem!

    I need to accept the date from three different dropdown viz. day,month and year(to avoid errors in writing date by the user).<BR>what will be my sql select statement as I want to search for that particular date.Please help!<BR>

  2. #2
    Join Date
    Dec 1969
    Posts
    511

    Default RE: Date Problem!

    That system has its problems as you can&#039t alter the contents of select boxes at run time so have to have all the days avalible no matter what the month is. So users could select 31/02/99 which is a date that does not exist! <BR><BR>I&#039ve looked at this method before and came to the conclusion that client side validation using javascript and a text field was a better option then three select boxes.<BR><BR>But if you do what to do it your way, don&#039t get me wrong it can be done that way, I&#039d use some VBscript on the accepting ASP page to join the three dates together as one and then store them as one field in your database or what ever.<BR><BR>Pete

  3. #3
    Adalsteinn Ottarsson Guest

    Default RE: Date Problem!

    Note that a Date/time entry in a Database would be <BR>dd.mm.yyyy or mm.dd.yyyy depending on the system<BR>but you also need the time prefix 00:00:00:000 .. So you need to combine all the three Rquests and the Time prefix into the Select statement so you wont get a Datatype mismatch error

  4. #4
    Sam Otto Guest

    Default RE: Date Problem!

    Here is my JavaScript routine I use to do client side validation of a date field...<BR><BR> //-----------------------------------------------------------<BR> // Validate a input field that holds a date.<BR> // field should be the input field<BR> // blank should be true if empty field is OK.<BR> //-----------------------------------------------------------<BR> function checkDate(field,blank)<BR> {<BR> alert(field.name);<BR> if (field==null)<BR> {<BR> alert("field is null!!!!");<BR> }<BR> str = field.value;<BR> if (str==null)<BR> {<BR> alert("str is null!!!!");<BR> }<BR> if (blank && str=="") return true;<BR> re3 = new RegExp("([0-9]{1,2})[ -/]([0-9]{1,2})[ -/]([0-9]{1,4})");<BR> if (str.search(re3)==0)<BR> {<BR> m = RegExp.$1;<BR><BR> if (m&#060;=12)<BR> {<BR> max = 31;<BR> }<BR> y = RegExp.$3;<BR> if (y&#060;100)<BR> {<BR> if (y&#060;20)<BR> y = 20 + y;<BR> else<BR> y = 19 + y;<BR> }<BR> if (y&#060;1999 &#124&#124 y>2000)<BR> {<BR> alert("Invalid date. Year must be 1999 or 2000");<BR> return false;<BR> }<BR> if (m==2)<BR> {<BR> if ((y%4==0) && (y%400!=0))<BR> max=29;<BR> else<BR> max=28;<BR> }<BR> else if (m==4&#124&#124m==6&#124&#124m==9&#124&#124m==11)< BR> {<BR> max = 30;<BR> }<BR> d = RegExp.$2;<BR> if (d&#060;=max)<BR> return true;<BR> }<BR> }<BR><BR>I usually make my input tag a maxlength and size of 10. I either call the function from a validate() function called on submission or when you exit the input field (onChange or onBlur)


  5. #5
    Join Date
    Dec 1969
    Posts
    119

    Default RE: Date Problem!

    Hi Rupali<BR>I think I can help you in this regard. I have devised a method by which your problem can be solved and I am using that in my applications.<BR>For details mail me at<BR>sinha_arvind@hotmail.com<BR> <BR>Arvind

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •