Click to See Complete Forum and Search --> : Date functions between VB & SQL Server


jibble-depop
October 30th, 2000, 06:21 AM
I am writing a security module and have a function to extract an expiry date from the SQL Server database which is compared against the system date. If the system date is after the expiry date then the user is prompted to change password. Example code :

If Date > dtePasswordExpiry Then
frmChangePassword.Show
frmChangePassword.txtUsername.Text = strUsername
frmChangePassword.txtOldPassword.Text = strPassword
End If

There is also a function to do the same but for User account expiry dates.

My problem is that although the system date (using the Date function [the same happens if I use Now()]) is before the date given in the variable dtePasswordExpiry it continues to begin the process to change password.

Any thoughts on why this is. It happened for the first time today (it previously worked fine since its creation). We changed from Daylight Saving Time back to GMT over the weekend, would this have any effect? Clutching at straws here!

Thanks for your help,
Colin

jibble-depop
October 30th, 2000, 06:27 AM
I should have mentioned that if I change the forementioned code so that the IF statement reads 'If Date < dtePasswordExpiry Then' instead of 'If Date > dtePasswordExpiry Then' it works okay. This seems weird to me as it makes sense to have it eg. if the system date is greater than (ie. after) the date the password expires then ..... But if I change the code to do what I think is the opposite, then it works. Hmmmm.
The dates I am using are todays date (30/10/2000) and the expiry date (01/08/2001)

Thanks again

dfwade
October 30th, 2000, 07:35 AM
looking at your code I would think that you might want to make a change to your query. Currently the clients date time appears to be date you are comparing against, wouldn't you want to check the servers date time. You can do this by adding to your select query select getdate() - passworddate from table this would return an integerto check and your date math would not matter.


TANSTAAFL - There ain't no such thing as a free lunch