• Date formats (ASP)

    Author
    Topic
    #440252

    This is probably not the forum, i would appreciate where i could be directed to to find the answer.

    How are the formats defined in ASP forms?

    Viewing 2 reply threads
    Author
    Replies
    • #1054231

      Forms presented in the browser, right?

      Are you using ASP.Net with Visual Studio, or ASP Classic with your choice of editors? Actually, in either case I’d guess JavaScript, as that is more cross-platform than ActiveX.

      • #1054263

        It is operated in IE.

        As to what they (a client) are using, i don’t know at this stage.

        The backend database is Access and it had a format for the dates as mm/dd/yyyy, i changed them to nothing so it picks up the Control panel’s dtate formats, this has worked quite well.

        My problem now is after changing the Access database for these date formats i cannot add a record using ASP.

        • #1054267

          I think you need to write code for this, as there is no such thing an an HTML date field. What is posted by an HTML field is just a string. That “date” string might contain 3/1/07 or 31/99/4567 or pestilence. You can use JavaScript in the page to try to coax the user into providing valid input, but your ASP script will need to determine whether the input is a valid date and, if so, whether it is within an acceptable range, before trying to write to the database.

          • #1054269

            Thanks Jefferson.

            I need to get a reference for ASP to work out how to do this.

            Do you know of any good ASP documents to read up on?

            • #1054473

              The ASP books I’ve bought have mostly been a bust, except for quick reference guides like ASP in a Nutshell. There are numerous ASP sites, and although many have switched to covering ASP.Net, there is plenty of old ASP content out there on the web. Also, your VBA resources should help, because very similar tools are available (the most critical omission might be the user defined date formats, but you can roll your own by extracting the individual elements, month, day, year, etc.).

            • #1054485

              Depending on what the clients to do (i am trying to persuade them into using Access instead of ASP) will determine if i continue down the ASP reference purchase path.

    • #1054232

      It’s been a while since I’ve used ASP, but this link should hopefully do the trick…

      • #1054264

        Thanks for your input, i have noticed that some ASP code does input using US date format.

        I don’t know how to code in ASP so i have gone back to the client saying i cannot help.

    • #1054476

      Hi Pat

      I think you need a function, something like this:

      function gb_SQLDATE(d) ' make "#day/month/year#" from date
        dim strYear,strMonth,strDay
        strYear = CStr(Year(d))
        strMonth = CStr(Month(d))
        if Month(d) < 10 then
      	strMonth = "0" & strMonth
        end if
        strDay = CStr(Day(d))
        if Day(d) < 10 then
            strDay = "0" & strDay
        end if
        SQLDATE="#" & strDay & "/" & strMonth & "/" & strYear & "#"
      end function
      

      You will want to play with code to get it to work but you could use it as an include to your main form

      • #1054486

        Thanks Jerry, but i’m not sure what the client wants to do going forward in time.

        When you make a change to an .asp file, do you just use notepad to change the file then test the code using IE? Or are there special tools to change and test .asp programs?

        • #1054487

          I use Notepad/Textpad/EditPlus depending which PC/Laptop/Server I am on. I then dump it in a virtual directory and test in my browser, so yes.

        • #1054494

          As an aside, .asp doesn’t run in a browser just from the hard drive. You definitely need an instance of Microsoft IIS in order to see how the ASP page will be interpreted.

          (From personal experience, it is very bad to create a loop through a RecordSet without having rs.MoveNext anywhere in the loop. laugh )

          • #1054501

            Thanks for that.

            ha ha about the rs.MoveNext, also make sure it is executed and not just in the loop.

    Viewing 2 reply threads
    Reply To: Date formats (ASP)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: