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 2005 Forums
 Transact-SQL (2005)
 Checking for Valid Date

Author  Topic 

rauof_thameem
Starting Member

31 Posts

Posted - 2007-05-15 : 12:45:43
Hi floks..,

I am getting day,month,year from diffrent places, i want to check the date is valid or not like..,

Day:30
Month:February
Year:2006

1)this date is not a valid one because feburary cannot be 30..

2)same for other months also which have 30 days..

3) checking for the given date is weekday or weekend,if it weekend add a day to get weekday

nr
SQLTeam MVY

12543 Posts

Posted - 2007-05-15 : 13:18:38
You can use isdate to check for a valid date - be careful if you don't have a name for the month.

After converting to date
if datename(weekday,@date) in ('Saturday','Sunday')
select @date = @date + 1

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

matty1stop
Starting Member

37 Posts

Posted - 2007-05-15 : 13:59:44
I don't think the above would work for a Saturday. Then you would want to add 2, right?
Go to Top of Page
   

- Advertisement -