Erik. Posted February 6, 2007 Share Posted February 6, 2007 Hello, I have a big database whit people. I want to know who is 16 years old, how to do that? I know you can do that whit this year-age but that is not precisely enough. example. When it is 05-02-2007 Europe date My birth day is at 06-02-1991 When i scan that person will say that he is 16 but he is tomorrow 16. How to calculate that? Gr Erik I little problem, hard to find and fix Link to comment Share on other sites More sharing options...
/dev/null Posted February 6, 2007 Share Posted February 6, 2007 _DateDiff() __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Erik. Posted February 6, 2007 Author Share Posted February 6, 2007 Hi, Thanks, will do a try I little problem, hard to find and fix Link to comment Share on other sites More sharing options...
Erik. Posted March 4, 2007 Author Share Posted March 4, 2007 Hi, I now want to add this option to my program.. Now do i have a little problem: in Europa we have the day format in DD/MM/YYYY and whit _DateDiff i need YYYY/MM/DD How to fix it whitout changing my settings? I little problem, hard to find and fix Link to comment Share on other sites More sharing options...
xcal Posted March 4, 2007 Share Posted March 4, 2007 (edited) StringSplit($date, '/') Edit - Or better yet... _DateTimeFormat() Edited March 4, 2007 by xcal How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
ghetek Posted March 4, 2007 Share Posted March 4, 2007 Hi, I now want to add this option to my program.. Now do i have a little problem: in Europa we have the day format in DD/MM/YYYY and whit _DateDiff i need YYYY/MM/DD How to fix it whitout changing my settings? just do a string strip using the "/" as a delimiter and then rearrange $datestring = "DD/MM/YYYY" $newdatestring=StringSplit($datestring,"/") msgbox(0,"here you go",$newdatestring[3] & "/" & $newdatestring[2] & "/" & $newdatestring[1]) cheers! Link to comment Share on other sites More sharing options...
xcal Posted March 4, 2007 Share Posted March 4, 2007 Hi, here's your fish! How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
Erik. Posted March 4, 2007 Author Share Posted March 4, 2007 wow lol thanks.. a was trying to make it at my own but you are faster:P It is a long time ago that i uesed autoit ... I little problem, hard to find and fix Link to comment Share on other sites More sharing options...
Erik. Posted March 18, 2007 Author Share Posted March 18, 2007 Hello, I have a little problem whit this script.. It now calculates the age of a person.. when i add someone and at the input of the birth day i full in a . then the program crash because it can not calculate.. But when it sees an error it needs to the this birth day: 0-0-0000 whit to do that? I use the . when i did not made a card for a members and i need to add them to my program.. Could someone help me please. I little problem, hard to find and fix Link to comment Share on other sites More sharing options...
Das Ami Posted March 18, 2007 Share Posted March 18, 2007 Post your sourcecode, I don't really get your explanation. Link to comment Share on other sites More sharing options...
Erik. Posted March 18, 2007 Author Share Posted March 18, 2007 Hi, $bereken = StringSplit($string[7],"-") $berekenen = _DateDiff("y",$bereken[3] & "-" & $bereken[2] & "-" & $bereken[1],_NowCalc()) GUICtrlSetData($personage2,$berekenen) If $berekenen >15 Then MsgBox(0,"Leeftijd","Persoon is:" & $berekenen & " en mag niet meer naar binnen") Else EndIf This is the script.. it reads the age from a input normaly it is correct... When i did not made a card for a person i need to add then past so i only full there first and lastname, you need to use all inputs: firts name,lastname,streetname, city,age,telephone number so i use the . so the program sees that i added data into a input.. But then it can not calculate the age and it crash.. Hope you understand I little problem, hard to find and fix Link to comment Share on other sites More sharing options...
Erik. Posted March 18, 2007 Author Share Posted March 18, 2007 Here you have an example: #include <Date.au3> $input = InputBox("Leeftijd","geef uw geboorte datum op") $bereken = StringSplit($input,"-") $test = _DateDiff("y",$bereken[3] & "-" & $bereken[2] & "-" & $bereken[1],_NowCalc()) MsgBox(0,"",$test) save it and take a try.. when you go the inputbox you full in you birth day DD-MM-YYYY when u only put a . into it you go an error.. How could you make it when you full in some other then the birth day then it automaticly full in 0-0-0000 ? I little problem, hard to find and fix Link to comment Share on other sites More sharing options...
SadBunny Posted March 18, 2007 Share Posted March 18, 2007 / sorry stupid, my suggestion was wrong, must have done something wrong with test first time, doesn't seem to work.so anyway, what exactly do you want, a function that checks if your date has been entered in the right format, or a function that also accepts dates with . as delimiter? Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Erik. Posted March 18, 2007 Author Share Posted March 18, 2007 (edited) Lol een nederlander das fijn:P Mijn engels is heel slecht.. Ik had al aan zoiets zitten denken maar wist niet of dat wel ging vond het een rare error. Dat werkt. Nu heb ik een heel programma van 1300 regels en dat ga ik hier niet zomaar posten. Als ik nu een . of iets invul hoe kan ik hem dan automatisch de volgende datum in laten vullen: 0-0-0000? Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $berekenen = _DateDiff("y",$bereken2[3] & "-" & $bereken2[2] & "-" & $bereken2[1],_NowCalc()) $berekenen = _DateDiff("y",^ ERROR Edited March 18, 2007 by Erik. I little problem, hard to find and fix Link to comment Share on other sites More sharing options...
Das Ami Posted March 18, 2007 Share Posted March 18, 2007 save it and take a try.. when you go the inputbox you full in you birth day DD-MM-YYYY when u only put a . into it you go an error..How could you make it when you full in some other then the birth day then it automaticly full in 0-0-0000 ?Use StringIsDigit to check if it's numbers only. Link to comment Share on other sites More sharing options...
Erik. Posted March 18, 2007 Author Share Posted March 18, 2007 Who to lett it full in automaticly 0-0-0000 if it is not StringIsDigit? I little problem, hard to find and fix Link to comment Share on other sites More sharing options...
SadBunny Posted March 18, 2007 Share Posted March 18, 2007 Who to lett it full in automaticly 0-0-0000 if it is not StringIsDigit? This should work better: check $input for any characters other than ' - ' and digits. #include <Date.au3> $input = InputBox("Leeftijd","geef uw geboorte datum op") If StringRegExp($input,"[^-0-9]",0) Then ; <-- geeft 1 als er een ander character dan een - of een cijfer in staat MsgBox(0,"","De datum heeft het foute formaat.") Else $bereken = StringSplit($input,"-") $test = _DateDiff("y",$bereken[3] & "-" & $bereken[2] & "-" & $bereken[1],_NowCalc()) MsgBox(0,"",$test) EndIf Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Erik. Posted March 18, 2007 Author Share Posted March 18, 2007 Hi, I am trying this: $leeftijd = GUICtrlRead($nonage) If StringRegExp($leeftijd,"[^-0-9]",0) Then ; <-- geeft 1 als er een ander character dan een - of een cijfer in staat MsgBox(0,"","De datum heeft het foute formaat.") GUICtrlSetData($nonage,"0-0-0000") sleep(100) Else EndIf $bereken2 = StringSplit($leeftijd,"-") $berekenen = _DateDiff("y",$bereken2[3] & "-" & $bereken2[2] & "-" & $bereken2[1],_NowCalc()) If $berekenen >16 Then MsgBox(0,"Leeftijd","Persoon is:" & $berekenen & " en mag niet meer naar binnen") Else EndIf But it does not work... I little problem, hard to find and fix Link to comment Share on other sites More sharing options...
SadBunny Posted March 18, 2007 Share Posted March 18, 2007 $leeftijd = GUICtrlRead($nonage) If StringRegExp($leeftijd, "[^-0-9]", 0) Then ; <-- geeft 1 als er een ander character dan een - of een cijfer in staat MsgBox(0, "", "De datum heeft het foute formaat.") GUICtrlSetData($nonage, "0-0-0000") Sleep(100) Else EndIf $bereken2 = StringSplit($leeftijd, "-") $berekenen = _DateDiff("y", $bereken2[3] & "-" & $bereken2[2] & "-" & $bereken2[1], _NowCalc()) If $berekenen > 16 Then MsgBox(0, "Leeftijd", "Persoon is:" & $berekenen & " en mag niet meer naar binnen") Else EndIf But it does not work... 1) First you read an age from some GUICtrl. Then you check with my regexp line whether this age contains a 'non-date' character, and try a date calculation with it. I would presume that some age that you read is a number, not a date. Put a date in the $leeftijd (and rename it to $datum or something ) and this should work... 2) Next you set the GUICtrl $nonage to a date, but you don't re-read that new date (0-0-0000) into the variable so if one enters it in a wrong format, it keeps the same wrong format in the second part which is always executed no matter if you enter the right format. Suggestions: either don't execute the calculation as long as the date is not in the right format, or put 0-0-0000 in your date variable and do the calculation (but have a weird result - i would go with the first suggestion). Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Erik. Posted March 18, 2007 Author Share Posted March 18, 2007 (edited) Hi, Yes that was what i am doing wrong:P I already found it but that is always when i post something:P Hi, that works now.. you only can full numbers into it.. is there a way to check if it is right??? because i can full in 1111 and it accepts the term and then my program crash... I need a - into it.. Edited March 18, 2007 by Erik. I little problem, hard to find and fix Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now