IsDate Problem
When I use isdate("31/04/01") it is interpretingas '01/04/1931" and returned true.Is there any way to interpret it '31/04/2001' whenwe give 2 digit year and return false.In SQL Server this is interpreted correctely.tHANKS FOR ANY SUGGESTIONS
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
IsDate
today i've noted that i'm doing one thing rong in my application. this error is separated in two parts. 1 - In SqL database i set field date as 'nchar', 2º in my application i didnt set that date was date. Well.. When i build the search form to search received letters. when i set to search between date1 and date2 the program sometimes doesn't return the correct data. I discovered was because the date. It seems he doesn't recognize records between 01-09-2006 and 05-10-2006. When i change the month to 01-10-2006 he can return me the correct results. I'm trying to use IsDate Command to tell that field is date type, and i hope this may solve my problem. Is this the best way ??
PS. How do i use correctly IsDate command ? Isdate(txtdate.txt) ?
Help With IsDate
Hi,
I have a VB app that sets an account expiry date for Active Directory accounts however if I don't specify an expiry date then the account is set to expire on 28th Dec 1899! (I believe this is a cdate or isDate issue). I've narrowed the fault down to the code below, if the code below is excluded from the program the account expiry date is set to 'Never' as I would expect. Please take a look and if you can help I'd love to here from you.
Thanks
If Not (Trim(newUser.DateExpires) = "") Then
If (IsDate(newUser.DateExpires)) Then
objNewUser.AccountExpirationDate = newUser.DateExpires
objNewUser.SetInfo
If (Err.Number <> 0) Then
doMsg ("Could not set the account expiration date for user " & newUser.SAMAccountName & ". Error : " & Err.Description)
Err.Clear
End If
End If
End If
IsDate
Can anybody explain why IsDate("01/01/2 ") = true?
Problem With IsDate() , Please Help
Dear All.
I have discovered the following
Code:
MsgBox IsDate("1a")
This returns 'True' !!!!!!!!!!!!!!!!!!
I discovered this flaw when testing a Database app.
Can anyone tell me if there is a Proper way to determine if
a value is actually a vaild date?
Many thanks
GT
IsDate Function
I there, can somebody explain me how works that function...
I've tried it but it does not catch wrong dates...(i.e 32/07/03 or 03/07/32 ) I don't know if it's the date format that I use or the way I use it but... Thanks
IsDate Function
hi all,
I need to validate date type of data ... im using isDate function for this
but it is giving me true even if
isDate("01/12/196") or isDate("01/12/19")
why this is so ... and how could i handle it that it returns me false for this kind of date
IsDate Function
Hi
The IsDate function returns a Boolean value that indicates whether expression is capable of being converted to a date value.
can someone gave me an Example using the IsDate and what common errors can occur using the IsDate function
i already tried the one that calculates the age (example)
IsDate() Lunacy!!!!!
Hi,
Could anyone please tell me why IsDate(strValue) is returning true, when the value of strValue is 7540112-2.
Strangely the following values return false:
7549112-2
7548112-2
7547112-2
7546112-2
but the following values return true:
7545112-2
7544112-2
7543112-2
7542112-2
7541112-2
7540112-2
It would take me too long to explain what the app is but trust me sometimes the values are dates and have to be formatted correctly.
Many thanks
Simon
IsDate() Not Working?
Hi,
I want to validate a date. I have a Month, Day and Year from user and wanted to use IsDate() along with DateSerial() but for some reason it doesn't work.
Here's my code (I'm passing incorrect month (13) and it still returns "Correct date". How can I check for correct date based on year, month & day?
VB Code:
Private Sub Command1_Click() If IsDate(DateSerial(2004, 13, 20)) Then MsgBox "Correct date" Else MsgBox "Wrong date" End IfEnd Sub
IsDate() Function
Im want to validate my textbox when user input date. I have view a lot of threads and saw a lot of pple using IsDate() function... but will this function be able to recognise leap yr??? like 29/02/2000 (dd/mm/yyyy)?
IsDate() .. Explain This One!
hello all.. I have a brain teaser/ VB problem for you.. Why does IsDate("11-3284019") return true? Take a look at the code below:
VB Code:
Sub duh() Msgbox(IsDate("11-3284019") ) 'True Msgbox(Month("11-3284019") ) '11 Msgbox(Day("11-3284019") ) '01 Msgbox(Year("11-3284019") ) '7219End Sub
Is this a flaw in M$'s IsDate Function?
Thanks,
-mcd
IsDate Function
Aaaggghhh IsDate("0.00") = True!!!! Pain in the arse . . . .
VB Code:
If IsDate (strItem) Then strItem = Format$(strItem, "dd-mmm-yyyy")End If
if strItem is a numeric string ie "0.00", "1.5" etc. then this returns a true. I assume that this is because it's interpreting it as the number of days since 31-dec-1899.
Pain in the arse, what use is a validation function that only fails non-numeric characters?
Rant over . . . .
IsDate Function?
how come whenever i use the IsDate function i can't have it to work
If IsDate("txtDob.text") = False Then
MsgBox "Please enter a valid date!", vbOKOnly, "Warning"
txtDob is a maskedEdit box
how do i set the format i want for it and have it tested with the IsDate function??
thanks in advance
Isdate Function
Hi,
I used isdate() in VB to see if the data is date 'mm/dd/yyyy'. But i also get 16:00 as date. Is there anyway i can get rid of the time as date, keep only date like 12/23/98?
thanks
Problem W/ IsDate()
I have the following code:
cmdOK_click()
if IsDate(Mask(0).Text) = False Then
MsgBox msgStr, vbOKOnly, "Error"
else
frmDate.hide
'do some other stuff
end if
endsub
Mask is a masked edit box. This piece of code works once, but won't work twice. If I enter an invalid date (i.e. 22/22/2001). Hit OK which triggers this procedure. Then, the watch on mask(0).text says "22/22/2001", and the IsDate is false. The msgbox displays. I hit OK on the msgbox. Everything seems fine......BUT
Then, I enter 11/22/2001 as my date. Hit the OK button which starts the procedure again. The watch on mask(0).text = "11/22/2001". However, my IsDate remains false and the msgbox is displayed again.
Anyone have any suggestions for what is going on?
NOTE: No other procedures are being called except for this one, and there is nothing else in the cmdOK_click procedure except elseif's under this same if statement.
Thanks for the help
IsDate - Not So Obvious
I realise that the IsDate function returns true if the argument passed to it can be converted to a date....but i'm not exactly sure what formats VBScript will recognise as dates....
the examples i've seen don't cover the format i want to use, so can somebody just provide a quick answer of what IsDate will return if i pass it a date in the format: 24/Jan/1984, that is, dd/mmm/yyyy....hopefully it will return true
IsDate With Textboxes
How would I put a date into for example textbox3.text from textbox1.text if textbox1.text contains other data aswell?
The below works, but only if the date is on its own and not with other letters and stuff.
Thanks if anyone can help.
[code]
Dim Birth As Long
For Birth = 1 To Len(Text1.Text)
If IsDate(Text1.Text) Then
Text3.Text = (Text1.Text)
End If
Next Birth
[code]
IsText, IsNumber And IsDate
Hi All
I am building a macro checking some DATEs on a spreadsheet. Because I have some dates which looks like a date but actually text (Thus, no calculate is allowed.), I need to pick out all those odd dates, so calculation can take place.
I am currently testing IsText, IsNumber under 'Application.WorksheetFunction....' in a macro and also use them directly in the spreadsheet. I have a confusing founding:
______________________MARCO_____________SPREADSHEET
Date_______________IsText____IsNumber____IsText____IsNumber
14/05/05 (Date)______TRUE_____FALSE______FALSE____TRUE
14/05/05 (text)_______TRUE_____FALSE______TRUE_____FALSE
14-May-05 (Date)_____TRUE_____FALSE______FALSE____TRUE
It doesn't seem to pick out what I want with macro at all. Any suggestion how to do this?
Thank you in advance.
IsDate Function - Getting Error- Please Help
I have a text box that allows the user to either use the calendar control to choose a date or they can enter a date in the text box on there own.
Either way, I format the date to appear as a "Long Date".
This all works great, except I validate the date on the textbox's validate event. The first time it converts the date to the "Long Date " format. If the user tabs through the textbox again, the validate fails because the IsDate function does not recognize the "Long Date " format as a proper date.
What can I do?
My validate event looks like this:
Dim strDate As String
strDate = txtMeetingDate.Text
If strDate = "" Then
'this is okay
ElseIf Not IsDate(strDate) Then
MsgBox "Invalid date"
txtMeetingDate.SelStart = 0
txtMeetingDate.SelLength = Len(txtMeetingDate.Text)
Cancel = True
Exit Sub
Else
'format the date here
txtMeetingDate.Text = Format(txtMeetingDate.Text, "Long Date")
End If
Cancel = False
End Sub
IsDate Format Date
I need some help here. It is about format date on IsDate Function. It seems, that i can't get it right. I hope you can assist me on this. This is what i am trying to achieve. User Input a date in MskEffective Date and automatically Isdate function generate an Expiry Date in MskExpiry. My Problem is each time i enter an effective date it prompt me an Error stated Invalid Property Value on <<FormName.mskExpiry = YearDate - 1>>. Below are my coding. I believe it is my coding problem. I have solved a couple of Error on Date but not this time. I am appreciate with anyone help. Thank you in advance.
VB Code:
Public Sub Validate(FormName As Form) IntervalY = "yyyy"If IsDate(FormName.mskEffective) = False ThenMsgBox "Date Wrong Format.Please check Date", vbCritical, "Date Format Incorrect"FormName.mskEffective.SetFocusExit SubEnd IfFirstDate = FormName.mskEffective 'FirstDate = Format(FirstDate, "dd-mm-yyyy")number = 1YearDate = DateAdd(IntervalY, number, FirstDate) 'YearDate = Format(FirstDate, "dd-mm-yyyy") 'FormName.mskExpiry = Format(FormName.mskExpiry, "dd-mm-yyyy")FormName.mskExpiry = YearDate - 1 'ExpiryDate Must Minus One DayEnd Sub
As you can see there are couple of Remarks which i tested out but all fail.
IsDate (CDate) Problem
Hello there! I'm facing a problem here and I hope someone could help. I have a (long) date string in the "English (United States)" Regional settings style (it's "24 Sep 2001 12:53").
I need to validate it and turn it to date. That's ok if I use the CDate function on that PC. However when I try that function on a PC with Italian(Swiss) regional settings (and some others) I get a "Type Mismatch" error and the IsDate doesn't recognise it as a valid Date!!
I was wondering if there's any way of having the string turned to date without having to change the Regional Settings.
Thanks for you time.
Dates, IsDate & DataFormat
Boy are dates getting me down!
Working in a UK locale ('dd/mm/yy'), I would expect IsDate to return false for IsDate("31/11/05"). If a date is entered as this value, surely it is likely to be due to the user forgetting there are only 30 days in November or accidentally entering the 11th month instead of, say, the 10th or 12th month. However, in its infinite wisdom, Vb6 decides they really mean 5th November 1931. The end result is that IsDate does not really do the job for me.
Has anyone had to deal with and resolve this problem before? I have tried coding around it but it seems to have become unncessarily complex - especially as I am trying to make the solution 'internationally friendly' and hence cope with different date formats.
A further related question - if you create a textbox on a form with DataFormat set to Date and format$, say, as 'dd/MM/yy' should this format automatically translate in different locales - e.g. in US would it become MM/dd/yy? If not, is there a way of setting the DataFormat to automatically adjust for different locales based on control panel settings?
Thanks in advance.
IsDate Function A Little Wierd
If somebody could help me with this one...
I wrote a program several months ago that will quickly download current quotes for stocks. Essentially, I am taking the web page and parsing it out to find my numbers.
This has been working nicely until today, when, the last of 6 stocks showed an error which I traced back to the "Isdate function" as follows:
I have a function that finds the data I am looking for and returns it as a string. To position myself, I look first for the date, which will then be followed by the open, high, low, close, and volume. To do this, I must go to the end of a table and use a backward counting For Loop, looking for the date. When found, I can then count back up to the linens I am looking for. Sounds worse than it is.
What happened this time follows:
In the For Loop that counts down, I have a lines:
Code: For n = arrSize To 1 Step -1
TempStr = SplitString(n)
CurrentStr = GetPriceData(TempStr)
If IsDate(CurrentStr) Then
'... get the data
arrSize = 8
When n = 8, the line is garbage, and IsDate = FALSE
Then, when n = 7, CurrentStr returns as "23.33" which is a closing value from the day before.
IsDate looks at this number [string actually] and returns TRUE. And this is even more peculiar, as when I look in the debugger, it is calling this Dec 30, 1899 at 11:33 PM. The 23.33 being a 24hour clock.
In any event, this screws up the normal sequence: when the date is found at n, n+1 = the openning price. As I said, the line at n = 8 is garbage, and I get a Type mismatch when it tries to convert it to a decimal number.
As I said, I have been using this for a number of months, and this is the first occurance. It is also probably the first time I read a stock that had a close below 24.00 [this is a tough market]. So, does this mean that any number below 24 will be mis-assigned. I would have thought that 23.33 would come out to Jan 23, 1900 at 8 in the morning.
And while we're on the subject, what can I do to easily get around this?
Thanx
Dave
IsDate Function Doesn't Work Like You Think
I've run across this problem and I want to see if anyone else has as well.
It appears as though the IsDate function works as a IsTime function as well. During my testing, however, I have discovered a major problem with this.
I enter "10:50" in my text box. This is a valid time, but an invalid date. This has the effect of, when I reformat the entered date, of giving me a date/time of "December 30, 1899 10:50:00." 12/30/1899 is the default date if none is given in the Date/time datatype.
Here's a code snippet:
Code:
If IsDate(sText) Then
WorkDate = CDate(sText)
txtTextBox.Text = Format (WorkDate, "mm/dd/yyyy hh:mm:ss")
Else
MsgBox "Not a valid date"
End If
Has anyone encountered this problem before? Is there a VB function to *just* check if a string is a valid date?
Thanks,
trapper
Isdate On A Date Separated With Points?
Hello,
I want to check if a date is a valid date with isdate, This works fine as long as you use "-" or "" a s a separator. How can i do the same with dates that are separated with points. So like this 11.3.2008
Thnx!!
Johan
Then Netherlands
Need Help Using ISDate() To Check For Specific Date Format...
I am curious,
'(I am using SQL to pull a field's date-data from Access2003 and displaying it to my users in txt(3).Text. I am designing this app in VB6.)
Can one of our forums' gurus explain the process I would use to verify that a date being entered is in this particular format only? dd/mm/yyyy
I know how to use the IsDate() but how can I use it to check the date format I desire?
I know I use Format(Date, "dd/mm/yyyy") when displaying the current date to my users so I assume IsDate() is similar only the current syntax I use yields errors.
I appreciate all your time and efforts,
Azeccia
|