Click here to Skip to main content
15,921,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have stuck with one issue.

I have a one textbox with calendar extender ,maskededit editor and mastededit validator ,which is could not valid for enter date 11/11/1111(MM/dd/yyyy) ,when this date pass to Sql server it is giving me SqlTypeException ,so in code behind i want to check the date is valid for Sql server or not before i pass it to Sql .

Any one has ideas about that???

Please help me out this???
Posted

You can pass a DateTime to DbCommand/SqlCommand and keep in mind for Sql server the first valid date is 1/1/1973 as mentioned here[^]
 
Share this answer
 
ya but i don't want to allow generate exception.i want to check it before i pass the date to sql.

by the way i got the solutions from below link

http://stackoverflow.com/questions/7054782/validate-datetime-before-inserting-it-into-sql-server-database[^]
 
Share this answer
 
Hi,

The default date format in sql server is YYYY/MM/DD.
My recommendation is to use the command "set dateformat" before execute your query in sql server to specify the date format that you will insert or update the database.

To the year question see http://msdn.microsoft.com/en-us/library/bb677335.aspx[^]

Cheers,
JAFC
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900