Date formats

Results 1 to 2 of 2

Thread: Date formats

  1. #1
    FretBuzzz Guest

    Default Date formats

    The purpose of the intranet application is to enable staff members to post leave requests. I use VBScript along with an MS-Access DB in the ASP. The site is hosted using NT4 server with IIS-4. The server&#039;s default date format is set to dd/MM/yyyy. All fields in the DB&#039;s tables which hold dates<BR>have been formatted to "ShortDate"<BR><BR>Scenario:<BR>When leave is requested, the ASP will tell the user whether or not the request can be posted successfully. The web application must make this decision based on a simple query which compares the user&#039;s input with whatever is found in the DB.<BR>The relevant DB Table consists of several fields among which a "DateFrom" and a "DateTo" fields are present. The user&#039;s input includes 2 dates (Leave - FROM and TO).<BR>These dates represent the date from which the user wants leave and the date until when the user wants leave.<BR><BR>Operation:<BR>When the user hits the "Submit" button the query filters the DB to hold only records where the user&#039;s "FROM" value, submitted on the form falls anywhere between the "DateFrom" and "DateTo" fields of of record. Similarly the ASP does the same with the "TO" value submitted in the same operation. If BOF or EOF is found to be true after the query executes, the user&#039;s leave is granted, and the details submitted on the form gets written to the DB. If not; the request is denied and a page displaying the clashing record&#039;s details appears.<BR><BR>Code snippet:<BR>Dim Connect, Show, Query, AreaClause, DateClause<BR>Set Connect = Server.CreateObject("ADODB.Connection")<BR>Connect .Open "MY_DB"<BR>Query = "SELECT * FROM my_leave WHERE "<BR>DateClause = "((leave_datefrom &#062;= #" & Request("datefrom") &"# AND leave_datefrom &#060;= #" & Request("dateto") &"#) OR (leave_dateto &#062;= #" & Request("datefrom") &"# AND leave_dateto &#060;= #" & Request("dateto") &"#))"<BR>Query = Query & DateClause<BR>Set Show = Connect.Execute(Query)<BR><BR>Problem:<BR>The results returned using/testing different date examples are inconsistent. It seems the ASP can&#039;t tell the difference between the U.S date format and that of the format I specified on the server, because it only works correctly when one of the date parts hold a value of greater than 12.<BR><BR>Actions taken:<BR>I have tried using the FormatDateTime() function - No luck<BR>I have tried changing everything to U.S format - No luck<BR><BR>Question:<BR>Can anyone help me please?

  2. #2
    Join Date
    Dec 1969

    Default RE: Date formats

    Seems like a silly question but have you compared the format of the field in the db to that in the code? I had a similiar issue and that solved the problem. Just a thought.

Posting Permissions

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