473,326 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

ASP Date problem

Hello Friend!

I am new for ASP. Database is Microsoft Access. So pls help me.....

My problem is ---

1. In login page, two text boxs. first textbox is username & second textbox is Password. Password is Date of Birth.

If DOB is starting 09-08-90 or 11-01-91 is not login or DOB is starting more than 13 (13-03-91 or 28-11-91) is succefully login.
2. So I check, How? the date is print. Below code

Expand|Select|Wrap|Line Numbers
  1.     if IsDate(rs("DOB")) then
  2.      Response.Write(CDate(pwd) & "<br>")  --- output is (11/2/90)
  3.      Response.Write(rs("DOB") & "<br>") --- output is (2/11/90)
  4.    else
  5.      Response.Write("Error")
  6.    end if
3. How i can solve this?
4.Because in my program, I check the ( if rs("DOB")= CDate(pwd) then)
Pls check the below coding... and reply me immediately is very very urgent advances thanks.......
Expand|Select|Wrap|Line Numbers
  1.  
  2. <%
  3. dim uname
  4. dim pwd, password, varDate 
  5. uname = Request.Form("txtUname")
  6. uname = UCASE(uname)
  7. Session.Contents("IDNO") = uname
  8. pwd = Request.Form("txtPwd")
  9. Set rs = Server.CreateObject("ADODB.Recordset")
  10. Set rs.ActiveConnection = my_Conn
  11. rs.Open "SELECT * FROM " & TBL_Data &" where "& TFL_IDNO & " = '" & Session.Contents("IDNO") & "'", my_Conn, 1
  12. if rs.RecordCount = 0 then
  13.  rs.Close
  14.  my_Conn.Close
  15.  set rs=nothing
  16.  set my_Conn=nothing
  17.  Response.Redirect("verify.asp?Submit=namefailed")
  18. end if
  19. if isdate(pwd) then
  20. if rs("DOB")= CDate(pwd) then
  21.  rs.Close
  22.  my_Conn.Close
  23.  set rs=nothing
  24.  set my_Conn=nothing
  25.  Response.Redirect("verifyParticulars.asp")
  26. end if
  27. else 
  28.  alert("Wrong Password Format")
  29. end if
  30.  rs.Close
  31.  my_Conn.Close
  32.  set rs=nothing
  33.  set my_Conn=nothing
  34.  Response.Redirect("verify.asp?Submit=passfailed")
  35.  
  36. %>
Oct 7 '08 #1
7 2202
Hello Friend!

I am new for ASP. Database is Microsoft Access. So pls help me.....

My problem is ---

1. In login page, two text boxs. first textbox is username & second textbox is Password. Password is Date of Birth.

If DOB is starting 09-08-90 or 11-01-91 is not login or DOB is starting more than 13 (13-03-91 or 28-11-91) is succefully login.
2. So I check, How? the date is print. Below code

Expand|Select|Wrap|Line Numbers
  1. if IsDate(rs("DOB")) then
  2. Response.Write(CDate(pwd) & "<br>") --- output is (11/2/90)
  3. Response.Write(rs("DOB") & "<br>") --- output is (2/11/90)
  4. else
  5. Response.Write("Error")
  6. end if
3. How i can solve this?
4.Because in my program, I check the ( if rs("DOB")= CDate(pwd) then)
Pls check the below coding... and reply me immediately is very very urgent advances thanks.......
Expand|Select|Wrap|Line Numbers
  1. <%
  2. dim uname
  3. dim pwd, password, varDate 
  4. uname = Request.Form("txtUname")
  5. uname = UCASE(uname)
  6. Session.Contents("IDNO") = uname
  7. pwd = Request.Form("txtPwd")
  8. Set rs = Server.CreateObject("ADODB.Recordset")
  9. Set rs.ActiveConnection = my_Conn
  10. rs.Open "SELECT * FROM " & TBL_Data &" where "& TFL_IDNO & " = '" & Session.Contents("IDNO") & "'", my_Conn, 1
  11. if rs.RecordCount = 0 then
  12. rs.Close
  13. my_Conn.Close
  14. set rs=nothing
  15. set my_Conn=nothing
  16. Response.Redirect("verify.asp?Submit=namefailed")
  17. end if
  18. if isdate(pwd) then
  19. if rs("DOB")= CDate(pwd) then
  20. rs.Close
  21. my_Conn.Close
  22. set rs=nothing
  23. set my_Conn=nothing
  24. Response.Redirect("verifyParticulars.asp")
  25. end if
  26. else 
  27. alert("Wrong Password Format")
  28. end if
  29. rs.Close
  30. my_Conn.Close
  31. set rs=nothing
  32. set my_Conn=nothing
  33. Response.Redirect("verify.asp?Submit=passfailed")
  34.  
  35. %>
Oct 7 '08 #2
DrBunchman
979 Expert 512MB
Hi shivasusan,

Welcome to Bytes.com. Please don't double post your questions - it is against the rules laid out in the Posting Guidelines. If you wish to add more information or you want to 'bump' your thread back to the top of the list then you can simply reply to it.

Please don't forget to wrap your code in CODE tags - it makes your posts much easier to read.

You have posted another question about date formatting in the forum which I have answered - does this help you with the problem above? If not can you try to explain your problem again as i'm not sure what it is - are you getting an error?

Dr B
Oct 7 '08 #3
jhardman
3,406 Expert 2GB
This is a common problem. In the US the standard date format is mm/dd/yy (because we would say October 7th rather than 7th of October) whereas in the rest of the English-speaking world the standard date format is dd/mm/yy. Since MS is a US-based company, unless you specify otherwise, all MS products assume that date in US format is correct, but dates in other formats are incorrect and are recorded as text, not as a date. To resolve this issue, all dates must be saved in unambiguous date formats (such as 2008-Oct-07 or 07-Oct-2008) or specify that this field in the db is a text field rather than a date field.

Jared
Oct 7 '08 #4
This is a common problem. In the US the standard date format is mm/dd/yy (because we would say October 7th rather than 7th of October) whereas in the rest of the English-speaking world the standard date format is dd/mm/yy. Since MS is a US-based company, unless you specify otherwise, all MS products assume that date in US format is correct, but dates in other formats are incorrect and are recorded as text, not as a date. To resolve this issue, all dates must be saved in unambiguous date formats (such as 2008-Oct-07 or 07-Oct-2008) or specify that this field in the db is a text field rather than a date field.

Jared
Hi Jared!

Thanks for your reply.

I try to convert the date dd/mm/yy to mm/dd/yy. I got answer, but i don't know its correct way. Please check my coding and reply me...

Expand|Select|Wrap|Line Numbers
  1. <%
  2.  
  3. dim uname
  4. dim pwd, password, changepwd
  5. dim mm, dd, yy, mmddyy, repwd
  6.  
  7. uname = Request.Form("txtUname")
  8. uname = UCASE(uname)
  9. Session.Contents("IDNO") = uname
  10. Session.Timeout = 120
  11.  
  12. pwd = Request.Form("txtPwd")
  13.  
  14. repwd=Replace(pwd,"/","_")
  15.  
  16. dd = Mid(repwd,1,2)
  17. mm = Mid(repwd,4,2)
  18. yy = Mid(repwd,7,2)
  19.  
  20. mmddyy = mm & "/" & dd & "/19" & yy  
  21.  
  22. Set rs = Server.CreateObject("ADODB.Recordset")
  23. Set rs.ActiveConnection = my_Conn
  24.  
  25. rs.Open "SELECT * FROM " & TBL_Data &" where "& TFL_IDNO & " = '" & Session.Contents("IDNO") & "'", my_Conn, 1
  26.  
  27.  
  28. if rs.RecordCount = 0 then
  29.  rs.Close
  30.  my_Conn.Close
  31.  set rs=nothing
  32.  set my_Conn=nothing
  33.  Response.Redirect("verify.asp?Submit=namefailed")
  34. end if
  35.  
  36. if isdate(mmddyy) then
  37. password = FormatDateTime(mmddyy,0)
  38. if rs("DOB")= CDate(password) then
  39.  rs.Close
  40.  my_Conn.Close
  41.  set rs=nothing
  42.  set my_Conn=nothing
  43.  Response.Redirect("verifyParticulars.asp")
  44. end if
  45. else 
  46.  end if
  47.  rs.Close
  48.  my_Conn.Close
  49.  set rs=nothing
  50.  set my_Conn=nothing
  51.  Response.Redirect("verify.asp?Submit=passfailed")
  52. %>
Regards,
susan
Oct 8 '08 #5
jhardman
3,406 Expert 2GB
Changing to mm/dd/yy is only a partial fix and I wouldn't do that for something that is going to stay permanent. The best permanent fix would be to change it to Mmm/dd/yyyy or some such variation where Mmm is the three-letter abbreviation for the month.

This is the problem: If a user enters 10/12/2008 or 12/10/2008 there is no way you can be sure you know which date he means and there is no way to ensure that he will write it the same way next time (experienced internet users are used to seeing different formats requested depending on the regional location of the coder). It would be much better to select a date from a drop down list or calendar control, but I understand that is not ideal for a password.

You could make the field be plain text in the db (varchar(8 or 10)) and then it wouldn't matter what the user entered, it would be his responsibility to get it the same way the next time.

You could assume that all of your users are going to enter the date in the same format, then your solution is valid, but the easiest way would be to specify a different region coding in your asp script (as DrBunchman suggested in another thread recently, maybe it was posted by you, I don't remember) or in the db. But if you don't want to do that, the simplest solution would be to ask the users to enter the date in a format like this: "12/Oct/2008" or "12-Oct-2008". I have seen all sorts of variations on this format and all are accepted and interpreted correctly by the db, even when put in apparently random order. Then even if the site owner comes to you later and says, "I don't like the date format '12-Oct-2008'. Can we enter the date as 'October 12, 2008'?" and you can say, "why yes. I'll add a special patch to allow you to enter dates that way. It will cost you another $350 ." but you won't even have to do anything, because the db and the script will still know how to handle it.

From my point of view, the solution you give has the same weakness as the original, it just assumes that the other date format will be used. Does this make sense?

Jared
Oct 8 '08 #6
Changing to mm/dd/yy is only a partial fix and I wouldn't do that for something that is going to stay permanent. The best permanent fix would be to change it to Mmm/dd/yyyy or some such variation where Mmm is the three-letter abbreviation for the month.

This is the problem: If a user enters 10/12/2008 or 12/10/2008 there is no way you can be sure you know which date he means and there is no way to ensure that he will write it the same way next time (experienced internet users are used to seeing different formats requested depending on the regional location of the coder). It would be much better to select a date from a drop down list or calendar control, but I understand that is not ideal for a password.

You could make the field be plain text in the db (varchar(8 or 10)) and then it wouldn't matter what the user entered, it would be his responsibility to get it the same way the next time.

You could assume that all of your users are going to enter the date in the same format, then your solution is valid, but the easiest way would be to specify a different region coding in your asp script (as DrBunchman suggested in another thread recently, maybe it was posted by you, I don't remember) or in the db. But if you don't want to do that, the simplest solution would be to ask the users to enter the date in a format like this: "12/Oct/2008" or "12-Oct-2008". I have seen all sorts of variations on this format and all are accepted and interpreted correctly by the db, even when put in apparently random order. Then even if the site owner comes to you later and says, "I don't like the date format '12-Oct-2008'. Can we enter the date as 'October 12, 2008'?" and you can say, "why yes. I'll add a special patch to allow you to enter dates that way. It will cost you another $350 ." but you won't even have to do anything, because the db and the script will still know how to handle it.

From my point of view, the solution you give has the same weakness as the original, it just assumes that the other date format will be used. Does this make sense?

Jared
Hi!

Thank you, for your reply.

I changed the db fieldname into text. But my Boss didn't accept. Try to do the fieldname in date format, Pls help me.... is any way to do these....

Regards,
Susan
Oct 9 '08 #7
jhardman
3,406 Expert 2GB
Which part does your boss not like? Does he just want the db field to be a DateTime field? Does he insist the date needs to be entered by the user in a particular format?

Jared
Oct 9 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Laurence Neville | last post by:
This is regarding a change in the Short Date format under Hebrew Regional Settings, that has caused huge problems in our ASP web application. The change appears to have been introduced sometime...
7
by: martini | last post by:
Need help: I am trying to call a DB2 stored procedure that requires parameters: 4x int, date, varchar, int. I use VB6 & oledb. I'm using statements: cmd.CommandText = "{call db2admin.proc(1, 0,...
11
by: David B | last post by:
I have 2 querys with the following in the date criteria Between DateAdd("m",-6,(!!)) And (!!) Between DateAdd("m",-24,(!!)) And DateAdd("m",-6,(!!)) Problem is they both look at the same...
3
by: Dustin Wilson | last post by:
I have a problem with the following line of code. rstOutput! = FormatDateTime("January 1, 2004", vbLongDate) When I run this on my computer at home it runs without problem but when I run it at...
3
by: Lyn | last post by:
Hi, I am developing a project in which I am checking for records with overlapping start/end dates. Record dates must not overlap date of birth, date of death, be in the future, and must not...
2
by: Julie Wardlow | last post by:
Help! I am calculating a future date using the DateAdd function in a query (the calculation also involves an IIf statement), and have managed to get this formula to produce the required result....
1
by: TN Bella | last post by:
Hello, I was looking through the older posts for a solution to this problem, but I am still confused on how to fix my problem. There are two dates on my form, one (txtInvDate) is entered by the...
7
by: James P. | last post by:
Hello there, In my asp.net page using VB, I have a date text field in mm/dd/yyyy format. When a date is entered, I'd like to validate it to make sure the date is greater than or equal to the...
13
by: Jim Armstrong | last post by:
Hi all - This problem has been driving me crazy, and I'm hoping the answer is something stupid I am neglecting to see.... The procedure posted below is part of an Access/SQL database I have...
7
by: creative1 | last post by:
Hello everyone. I am experiencing a strange problem that I can't fix on my own. I think I need expert's suggestions for this. The problem is: I want to print account statement (or any other...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.