Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.0 ASP.NET
Hi Friends,
I have string value is "Week 9 (or) Current week: 2/24/2013 - 3/2/2013"
 
But I want startdate as "2/24/2013" and EndDate as "3/2/2013" into DATETIME.
 
How can i convert it. Please help me.
Posted 28-Feb-13 4:41am
Edited 28-Feb-13 6:54am
ProgramFOX145.5K
v2
Comments
ThePhantomUpvoter at 28-Feb-13 9:44am
   
Have you tried the DateTime.Parse or TryParse methods?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can use Convert.ToDateTime() or the other methods mentioned by ThePhantomUpvoter.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

try this exampal code using regex..
string input = "Week 9 (or) Current week: 2/24/2013 - 3/2/2013";
MatchCollection matches = Regex.Matches(input, @"\d{1,2}/\d{1,2}/\d{4}");
DateTime dt =DateTime.Parse(matches[0].Value);
DateTime dt2 = DateTime.Parse(matches[1].Value);
also go through following link
Regular expression - String followed by a date[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Use
DateTime.Parse("2/24/2013");
  Permalink  

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



Advertise | Privacy | Mobile
Web01 | 2.8.150326.1 | Last Updated 28 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100