-
Jul 17th, 2010, 01:12 AM
#1
Thread Starter
Fanatic Member
Datetime problem
In windows 7 am facing the below problem, when converting datetime.
Code:
?Convert.ToDateTime("7/15/2010 9:18:40 AM").ToString("dd-MMM-yyyy")
Run-time exception thrown : System.FormatException - String was not recognized as a valid DateTime.
is there any error in converting.
Visual Studio.net 2010
If this post is useful, rate it
-
Jul 17th, 2010, 01:46 AM
#2
Re: Datetime problem
Your string is presumably in a format that is not recognised by your current culture. If you want to use a specific format then use a specific format, i.e. call Date.ParseExact and specify the format the string is in.
-
Jul 17th, 2010, 01:53 AM
#3
Lively Member
Re: Datetime problem
where you getting that datetime from vb.net... Is it from datetimepicker value? can you say correct problem of yours??
-
Jul 17th, 2010, 08:12 AM
#4
Re: Datetime problem
Originally Posted by vijy
In windows 7 am facing the below problem, when converting datetime.
Code:
?Convert.ToDateTime("7/15/2010 9:18:40 AM").ToString("dd-MMM-yyyy")
Run-time exception thrown : System.FormatException - String was not recognized as a valid DateTime.
is there any error in converting.
Assuming that you typed that into the debugger, I agree with John. I copied / pasted it into my debugger and it worked fine.
-
Jul 17th, 2010, 08:18 AM
#5
Lively Member
Re: Datetime problem
Try this..
dim dat1 as date
dat1 = datetimepicker1.value
'" & dat1.ToString("dd/MM/yyyy") & "'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|