forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Help on valid dates?

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
jwfv
Valued Contributor
Valued Contributor


Joined: 19 Mar 2002
Posts: 422
Location: Beaufort, SC

PostPosted: Wed Jun 11, 2003 1:21 pm    Post subject: Help on valid dates? Reply with quote

I have searched the forum and haven't found this topic. Any help is appreciated:

I have an edit box where the user enters a date. Then, when the data is saved, that date is saved in a database.

How can I check to make sure the date is valid before saving? I could do it either at the time it is saved, or before they exit the edit box.

I can't figure out how to use @datetime() to make sure the date is valid and not something like:

13/14/15

Thanks!

(PS - An alternative solution would be I guess to check that the date is X number of days away from today's date? - The date they will enter should always be within a couple of weeks of today's date .....)
Back to top
View user's profile Send private message
DW
Contributor
Contributor


Joined: 21 Mar 2003
Posts: 175
Location: UK

PostPosted: Wed Jun 11, 2003 1:37 pm    Post subject: Reply with quote

Im not really sure but couldnt you parse the three sections of the dateand then check it?

Example being, user enters 10/03/03

you could have your program take the days which would be 10, then the month which is 03, and finally the year, also 03.

after cutting up all the sections you could check each one.
Just a suggestion but i think it would work.
Maybe someone round here can show you what I have said in code form.

Hope that helps some.
Back to top
View user's profile Send private message
DW
Contributor
Contributor


Joined: 21 Mar 2003
Posts: 175
Location: UK

PostPosted: Wed Jun 11, 2003 1:49 pm    Post subject: Reply with quote

Im only a noob but would something like this do it?
Would need better checking routen.

Code:

:Init
  rem this makes parse use / instead of default which is |
  option fieldsep,/
 
:Main
  DIALOG CREATE,DateCheck,-1,0,240,99
  DIALOG ADD,EDIT,EDIT1,32,26,180,19
  DIALOG ADD,BUTTON,BUTTON1,52,144,64,24,Check
  DIALOG ADD,TEXT,TEXT1,16,26,,,Enter date (example 01/01/01)
  DIALOG SHOW
:Evloop
  wait event
  goto @event()
:BUTTON1BUTTON

  rem cuts up the date from edit1 and put it into %%day, %%month and %%year.
  %%DATE = @dlgtext(edit1)
  parse "%%day;%%month;%%year",%%DATE
 
  rem tells you what you entered.
  info the day is %%day@cr()the month is %%month@cr()and the year is %%year.
 
  rem example check, this is just simple stuff.
  rem im only a noob...
  if @greater(%%day,31)
    info not a valid day
  end
 
  goto evloop
:Close
  exit
Back to top
View user's profile Send private message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Wed Jun 11, 2003 2:25 pm    Post subject: Reply with quote

Well I get an exception: invalid date/time error when using this code:

Code:
if @ok(@datetime(mm/dd/yyyy, 13/14/1435))
info Valid Date
else
warn Invalid Date
end


Unfortunately there's no way to process the error, even with ERRORTRAP. Sad

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
jwfv
Valued Contributor
Valued Contributor


Joined: 19 Mar 2002
Posts: 422
Location: Beaufort, SC

PostPosted: Wed Jun 11, 2003 2:58 pm    Post subject: valid date Reply with quote

Thanks for the responses -

Yeah, I could break it up like in your example, DW - I may do that.

I was hoping for an elegant, one-line solution (of course.) But like FF shows in his example, checking @datetime on an invalid date just gives an error right off the bat.

Thanks for the help, though. I may modify the example parsing code and use that, if nothing else comes along.
Back to top
View user's profile Send private message
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Thu Jun 12, 2003 3:26 pm    Post subject: Reply with quote

you could also use 3 drop down boxes (one for the days, one for the months and one for the years)...this way you don't have to worry about checking dates...the down side is that you need to set the number of days depending on the month selected (eg. february)

or you can use 3 spin boxes...

Serge

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Tommy
Admin Team


Joined: 16 Nov 2002
Posts: 746
Location: The Netherlands

PostPosted: Sun Jun 15, 2003 8:41 pm    Post subject: Reply with quote

Also DLLs exist that have a datetime selection element (VDSOBJ 2?).
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jwfv
Valued Contributor
Valued Contributor


Joined: 19 Mar 2002
Posts: 422
Location: Beaufort, SC

PostPosted: Sun Jun 15, 2003 8:48 pm    Post subject: Reply with quote

Thanks for all the help. I'm going to look into it and see if the calendar function in that dll will suit my needs.
Back to top
View user's profile Send private message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sun Jun 15, 2003 9:26 pm    Post subject: Reply with quote

You can also use edit masking in the VDSOBJ02.DLL Smile
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group