Click here to Skip to main content
14,825,880 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello Experts

I am Using MaskedText Box For Entering Date And I Use MAsk is Shortdate
My Question is How To Validate This MaskedtextBoxt if it is Valid Date or Not
I try Using IsDate But That is Not Working Bcoz The Text in masked TextBox is eg "12 /02 /2008" like this
Also This Text How to Format Like yyyy/MM/dd for inserting in SQl
I also Use Format But This Already string So it cannot Be Format

Plz give me Suitable Reply , Urgent

Chaitanya
Posted
Comments
Karthik_Mahalingam 24-Jan-14 3:28am
   
post code

1 solution

You don't need to format anything! Date should be a date, not string!

If you want to insert data into SQL database, you should know the format which is used by MS SQL server. Have a look at SET DATEFORMAT[^] command.

Finally, you should use stored procedure[^]:
SQL
USE DataBaseName;
CREATE PROCEDURE InsertMyData 
    @myDate DATETIME
AS
BEGIN

SET DATEFROMAT dmy;
INSERT INTO TableName (DateField)
VALUES(@myDate)

END
   
Comments
phil.o 24-Jan-14 3:42am
   
I gave up counting how many times it has been said that dates/times should be handled as dates/times rathers than strings, and that formatting of these values should only be involved on the presentation side.
My 5 :)
Maciej Los 24-Jan-14 3:46am
   
Don't give up! Stand up and fight!

Your brother in arm
Maciej

Thank you, Phil ;)

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