Topic: More on dates

i wish to show a start date in datepicker2. i have this line in an 'on change'  event in datepicker1: form1.DateTimePicker2.DateTime:=sqlexecute('select startdate from seasons where id=seasonname' ). when i change the date in datepicker1 i get a date in datepicker2 but it is always some datein 1899. never the correct date.

Re: More on dates

Put your SqlExecute('Select.....' inside the parentheses of SQLDateTimeToDateTime( ). 

form1.DateTimePicker2.DateTime:= SQLDateTimeToDateTime(sqlexecute('select startdate from seasons where id=seasonname' ));

Re: More on dates

geves me error "" is not a valid date time

Re: More on dates

If I may ask. Why are you loading the datetimepicker field with a SqlExecute rather than letting MVD handle it on a form automatically? Since you have a null date, a check for it should be put in place. I modified the Pozidis example in another post for your situation. See if the attached is acceptable.

Post's attachments

Attachment icon Pozidis_Date_Reformat.zip 338.05 kb, 430 downloads since 2016-05-10 

Re: More on dates

Good Evening Lee, EHWagner,
Using a calculated field might be another way to go.
I've attached a quick example to show both options - and, as always, I'm sure there are other ways too ( I stick with what I can get to work, not what is necessarily the best!!)
Hope one approach or the other (or both) helps,
Derek.

Post's attachments

Attachment icon lhimesdatetimepicker.zip 338.11 kb, 441 downloads since 2016-05-10 

Re: More on dates

i use the weeksbetween to automatically give me the week number of play.  seemed like an easy way to do it to me.

Re: More on dates

couldnt get it to work for me. attached is sample of what im trying to do.

Post's attachments

Attachment icon Sample3.zip 5.4 kb, 416 downloads since 2016-05-10 

Re: More on dates

Hi Lee,
I've attached your project with a couple of changes that I hope will give you what you're after.
I think there were 2 basic issues with what you were trying to do.
1.  You were trying to use the seasonname as the ID whereas the ID is always an internally generated number (have a look at the sqlite.db screen shot that's included in the attached .zip file), so it was never going to find a match.
2.  There was no reference on your matches form to which season you were wanting to use, so I have added a combobox so you can either select the season manually from the drop-down or, if you have previously highlighted a row in form1.tablegrid1, then the script will pass that record ID through to the matches form automatically.
Trust that makes sense.
Derek.

Post's attachments

Attachment icon Sample3lh.zip 463.96 kb, 475 downloads since 2016-05-10 

Re: More on dates

hi Derek

once again you are right on point. works perfectly. i thought maybeit had something to do with the id but wasnt sure where to go with it. dont seem to be able to find any documentation on the function use. would appreciate it if you could give me some direction to go there.  again and again i appreciate all the help.


lee