# Date question

the norman example is great for me because i quickly understood the concept. sometimes a picture is worth a thousand words.
Anyway I really appreciate your great explanation @michael bujardet which along with the example code closes the circle to achieve a better understanding of the matter

The problem with this whole thread, is the problem you ASKED and the SOLUTION that Norman provided are NOT related.

You ASKED [quote]is there a way to check if a string is a date[/quote]
Normans solution assumed (which in later posts you said you were doing) that you have the 3 indiviual components already, where if all you had was a string, you have to GET those components, which was the direction everyone was trying to take you.

I was naive enough to think that you could understand the process and elaborate yourself the method from my description.

Instead of providing ready to paste snippets, it is often much preferable to learn how to do it yourself.

If you want to become a better programmer, you will have to learn how to elaborate a method and/or an algorithm for yourself.

Give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime.

[quote=306314:@Dave S]
Normans solution assumed (which in later posts you said you were doing) that you have the 3 indiviual components already, where if all you had was a string, you have to GET those components, which was the direction everyone was trying to take you.[/quote]

I assumed nothing
I read the thread & noticed he said he had 3 fields which everyone seemed to ignore for the duration of the thread

[quote=306282:@nicolscanessa]Maybe we all can create an opensource function called IsDate that works the same as in vb?? (Although perhaps it is a very crazy idea)

:-)[/quote]

But IsDate in VB suffers from the same problem ParseDate does in XOJO!!! There is no way to tell is a string is a date on it’s own unless you are give information about the source of the date string. Both IsDate and ParseDate relying on your underlying configuration to determine if the string is a date or not.

Here is the type of function you seem to want:

Function IsDate(Extends s As String) As Boolean
Dim d As Date
Return ParseDate(s, d)
End Function

Dim d As String = “30/12/2016”

If d.IsDate Then
MsgBox “Yes we have a date!”
End if

I know you didn’t ask for this but I prefer to use a date picker to force the user to enter a valid date.

See project attached to last post.

That’s why I spent so much time describing ambiguities and proposing a method. Next time I will know better. He does not want to learn, he wants snippets.

Getting stuffy in here anyway. Ignoring now.