Sign in to follow this  
Followers 0
jmangrum

Date Validation

8 posts in this topic

I have tried using the date validation and always comes back invalid. This is the code I am using.. Is there something simple that I am missing?

Thanks

$validtest = "Failed"

$sDate = @MON & "/" & @MDAY & "/" & @YEAR

Do

$maindate = InputBox ( $company, "Please Enter A Date That You Want To See The Reports From -- In the format dd/mm/yyyy" , $sDate )

If _DateIsValid( $maindate ) Then

MsgBox( 0, "Valid Date", $maindate & @error )

$validtest = "Passed"

Else

MsgBox (0, $company, "Invalid Date "& $maindate & " Please Try Again " & @error, 10 )

EndIf

Until $validtest = "Passed"


Joseph MangrumCCNA, CNA, MCP, Network+

Share this post


Link to post
Share on other sites



If _DateIsValid( $maindate ) Then

                MsgBox( 0, "Valid Date", $maindate & @error )

  $validtest = "Passed"

Else

  MsgBox (0, $company, "Invalid Date "& $maindate & " Please Try Again " & @error, 10 )

EndIf

<{POST_SNAPBACK}>

this may be nothing, but why have @error output on success?

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

this may be nothing, but why have @error output on success?

<{POST_SNAPBACK}>

Sorry, that was left accidentally to see if there was an error return code associated with it, and there is but if that is the case, then why run it as an IF statement. Even if it is out, still get all dates invalid since all I am doing is displaying it to see what it returns

Joseph MangrumCCNA, CNA, MCP, Network+

Share this post


Link to post
Share on other sites

I have tried using the date validation and always comes back invalid. This is the code I am using.. Is there something simple that I am missing?

Thanks

<{POST_SNAPBACK}>

I was sure i fixed this back in April but seems it slipped through the cracks...

The Helpfile is wrong and should say:

This function takes a date input in one of the following formats:

"yyyy/mm/dd[ hh:mm[:ss]]" or "yyyy/mm/dd[Thh:mm[:ss]]"

"yyyy-mm-dd[ hh:mm[:ss]]" or "yyyy-mm-dd[Thh:mm[:ss]]"

"yyyy.mm.dd[ hh:mm[:ss]]" or "yyyy.mm.dd[Thh:mm[:ss]]"

Example should say:

#include <Date.au3>

$sDate =  @YEAR & "/" & @MON & "/" & @MDAY

If _DateIsValid( $sDate ) Then
  MsgBox( 4096, "Valid Date", "The specified date is valid." )
Else
  MsgBox( 4096, "Valid Date", "The specified date is invalid." )
EndIf

Will submit the Doc correction to JP...


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Sorry, that was left accidentally to see if there was an error return code associated with it, and there is but if that is the case, then why run it as an IF statement. Even if it is out, still get all dates invalid since all I am doing is displaying it to see what it returns

<{POST_SNAPBACK}>

right, sorry i figured it out as soon as i started playing with it... one thing that i think is kind of interesting is that on the fail that @error is 0, which the help file says means no error... that made me think it may be an issue with your condition statement. i ran into something like this the other day where i was doing a stringinstr() with numbers, and even though i could plainly see that the sub string i was looking for was in the string being evaluated, it kept saying false... i'm going to look back at that and see if it's not a similar type of issue...

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

The Helpfile is wrong and should say:

[...]

Will submit the Doc correction to JP...

<{POST_SNAPBACK}>

Also, the help file says that the routine should set error codes to indicate the problem in processing the date, but there are not errors set in the source.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Also, the help file says that the routine should set error codes to indicate the problem in processing the date, but there are not errors set in the source.

<{POST_SNAPBACK}>

correct.... have changed that too....

here's the new helpfile page:

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

correct....  have changed that too....

here's the new helpfile page:

<{POST_SNAPBACK}>

Excellent, I see why that may have gone bad then. Thanks, that will help out alot. I will give it a run and if anything else comes up I will let you know.

Thanks for all the replies..


Joseph MangrumCCNA, CNA, MCP, Network+

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0