Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 valid date...

Author  Topic 

eddie
Starting Member

45 Posts

Posted - 2002-04-03 : 15:00:48
Is there a way that I can make sure a user inputs a correct date? For example if they put in an 11, I want to tell them it is invalid before I get to the statements which will cause an ugly sql error. What I mean is there an isdate function? I only want them to give me a date with a mask of mm/dd/yy or mm/dd/yyyy

Thanks,
Eddie

yakoo
Constraint Violating Yak Guru

312 Posts

Posted - 2002-04-03 : 15:03:21
what language are you writing in as your front-end

if it is VB or ASp ther eis an IsDate() function that will return Tree/False

Go to Top of Page

dsdeming

479 Posts

Posted - 2002-04-03 : 15:17:46
There is an ISDATE() function in TSQL. See BOL.

Go to Top of Page

yakoo
Constraint Violating Yak Guru

312 Posts

Posted - 2002-04-03 : 15:23:14
where are you trying to validate the date at? On the front-end or in the back-end in a stored procedure?

If you are doing it in the front-end you have many options, depending on what your front-end is. If you are doing it in a stored procedure you can use the IsDate() function in TSQL and throw an error. You will then have to capture that error and do something with it.

To capture errors take a look at:
http://www.sqlteam.com/item.asp?ItemID=2463
http://www.sqlteam.com/item.asp?ItemID=2841
http://www.sqlteam.com/item.asp?ItemID=6881

Go to Top of Page

Jay99

468 Posts

Posted - 2002-04-03 : 15:26:04
A wise man once said, "Do you user input validation in the front-end, not in the database(if you can)" . . . let's see, who was that . . . oh yeah . . . me


Jay
<O>


Edited by - Jay99 on 04/03/2002 15:30:38
Go to Top of Page

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2002-04-04 : 08:46:53
Yessssss.... because if you do it on the back end, the application developers will (gasp) have to write exception handling code!

quote:

A wise man once said, "Do you user input validation in the front-end, not in the database(if you can)" . . . let's see, who was that . . . oh yeah . . . me



setBasedIsTheTruepath
<O>
Go to Top of Page
   

- Advertisement -