on 2009 Sep 10 8:01 AM
Hi....
I have created a form using screen painter. In that i have assigned a textbox for date as date field. The user can enter the current date or the date which is lesser than current date while adding or updating. It should not allow the user, to enter the date which is greater than current date.
Regards
Roseline.B
Hi,
Follow what Satish and Kevin said, and just in case if ur stuck in the comparision of the dates.. Check the following links.
http://www.dreamincode.net/forums/showtopic63297.htm
U can find even more samples in google.
Happy Coding..
Vasu Natari.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Roseline,
In the Lost_Focus Event, for that particular field, you can make a check if the date is greater than the current date and if so, you can get the focus back to the date field and give a msg to the user asking him to enter the current date or a previous date.
Hope this helps.
Regards,
Satish. B.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Roseline,
This is how you subtract dates.
DateTime oDate;
DateTime oDate1;
Int16 DateDifference = oDate.Subtract(oDate1);
you get the DateDifference integer and if that is positive, then, it means the date is exceeding and you can delete the value and prompt the user to enter the correct date.
Hope this helps.
Regards,
Satish.
yeah Roseline,
You are correct, so in the above code snippet of mine, one of the dates will be your current date, preferably, oDate. So, once you get the datedifference integer as say 3, then, it means that, the date entered is 3 days ahead of the current date.
In that case, you need to handle the validation such that, you explicitly delete the entered value and ask the user to enter a proper date.
I guess your question is answered here.
Regards,
Satish.
Fine Roseline, then, what I would suggest you is, dont take datediff, take the rest of line in a message box and see in what datatype it comes, as
System.Windows.Forms.MessageBox.Show(oDate.Subtract(oDate1));
or MsgBox(oDate.Subtract(oDate1))
if your code is C# or VB.Net respectively.
Accordingly, you can assign it in integer or whatever and get it done.
Regards,
Satish.
I am doing in vb.net. In the message box itself it is showing error. I am getting the date value in the text box. The value is showing as string like this '20090915' if the date is '15/09/2009'. So I put
ODate1=otext.value
In that It shows a error as
"Conversion from '15/09/2009' to string is not valid
User | Count |
---|---|
111 | |
8 | |
8 | |
6 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.