×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to check whether the date is valid or not

How to check whether the date is valid or not

How to check whether the date is valid or not

(OP)
Hi,
I'm using a procedure in which i have to append the date by 1 unit, everytime the loop increases. I need to check whether the new processed date is valid or not. for eg: suppose my current date is 2007-02-28. on adding 1 it is giving me 2007-02-29. i hv to check whether it is a valid date or not thru a function. how can it be done..?? is there any inbuilt mechanism to check

RE: How to check whether the date is valid or not

(OP)
hi thnx for the reply actually the issue is that i hv writtena  certain peice of code :
***********************************************************
If fLastStmtDate1 Is Null Then
   Let fLastStmtDate1 = Date(fStmtNextDate) - 1 Units Month;
End If;
    
Let fLastStmtDate2 = Date(fLastStmtDate1) + 1 Units Day;
***********************************************************
 and in this part it is giving me the error -1267.. I am not gettign nay clue why this error is coming

RE: How to check whether the date is valid or not

I think the error is raised by the month line, not the day line.
I'd use a separate procedure for adding/subtracting months:

CODE

CREATE PROCEDURE AddMonth(dep DATE, nbm SMALLINT) RETURNING DATE;
  DEFINE res DATE; DEFINE nbj SMALLINT;
  LET nbj=0;
  WHILE 1=1
    ON EXCEPTION IN(-1267)
      LET nbj=nbj+1;
    END EXCEPTION
    LET res=DATE(dep-nbj UNITS DAY + nbm UNITS MONTH);
    EXIT WHILE;
  END WHILE
  RETURN res;
END PROCEDURE;
And now your actual code may look like this:

CODE

If fLastStmtDate1 Is Null Then
   Let fLastStmtDate1 = AddMonth(fStmtNextDate,-1);
End If;

Hope This Helps, PH.
FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions?
FAQ181-2886: How can I maximize my chances of getting an answer?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close