Library code snippets
How to convert a string to a date
By Edward Tanguay, published on 11 Jan 2003
Finding out how to convert one type to another in .NET is tricky. Here is the answer to converting a string to a DateTime type. Notice that any of the string formats work -- how nice!
//string strDate="2002-10-03";
//string strDate="10/04/2002";
string strDate="10/05";
DateTime dt = (DateTime)(TypeDescriptor.GetConverter(new DateTime(1990,5,6)).ConvertFrom(strDate));
Response.Write("<hr>" + dt.DayOfWeek);
Related articles
Related discussion
-
Buy cheap Xanax overnight. Cheap Xanax. Overnight delivery of Xanax in US no prescription needed. Cheapest Xanax.
by asleymar (0 replies)
-
Buy Soma online without a prescription. Soma drug no prescription. How to get Soma prescription. Soma cod accepted.
by asleymar (0 replies)
-
Cheap online order Fioricet. Cheap discount Fioricet. Offshore Fioricet online. How to buy Fioricet online without a prescription.
by asleymar (0 replies)
-
Buy Ambien no visa without prescription. Not expensive Ambien prescriptions. Ambien no rx. Cod delivery Ambien.
by asleymar (0 replies)
-
Tramadol without doctor rx. Buy Tramadol over the counter cod overnight. Cheap Tramadol cod delivery. Buy Tramadol from mexico online.
by asleymar (0 replies)
Related podcasts
-
Object-Oriented Programming in Ruby
In this episode, I talk with Scott Bellware about object-oriented programming in Ruby, and Ruby's object model. This is taken from a private conversation, and the audio quality suffers at times. Much thanks to Scott for allowing this to be released.This episode of the Alt.NET Podcast is bro...
'Converts the date in format dd/MM/yyyy to date format in MM/dd/yyyy
Dim stDate As String = "31/12/2006" Dim dtDate As DatedtDate = DateTime.Parse(stDate, Globalization.CultureInfo.CreateSpecificCulture(
"en-CA"))MsgBox(dtDate)
Hey, to ALL Developers and Programmers,
Here's a simple and easy way of solving all your Date Programming and Conversion problems.Developer's Dateware offers a much greater variety of date features, versus what is offered in typical programming environments. You will not need to fuss with the PC's Locale system any longer – these features will do it for you. These Date functions range from general areas to specific areas.
Developer's Dateware offers:1) simplicity in performing any kind of Date Operation.
2) much more capabilties, for a lot less money.
3) Excellent Results and Performance are Guaranteed .
And yet, we’ll beat the rest!
4) supports many different date formats...
Are you ready to take a challange for something new and much better?
DateFormats, and yes, I’m still around…
The software is written in MSVC++ v6.0, (with NO MFC Code).
For Further Details about Developer's Dateware Software and demo,
contact Thad at: auroraprojectusaf@yahoo.com--6/22/2008--
Svy,
Cheers mate that one had thus far eluded me.
DateTime startTime;
start = Convert.ToDateTime(startTimePicker.Text);
Console.WriteLine(startTime.ToLongTimeString());
The problem with this is that the results are string values but i want the actual time value in order to be able to use it to compare times to prevent overlaps in meeting times.
How can i get just date part (22/12/2003) out of datetime(22/12/2003/ 1:23:00 PM) without convert to string datetypes (ShortDateString etc).
for instance if ur passing datetime parameters to stored procedures that perform search based on dates supplied.
Passing dates with time would not show last record coz it compares with time too.
'you will get an error because november only has 30 days to it the correct string
'is "11/30/2003"
dim dateString as string = "11/30/2003"
dim convertedDate as Date = CDate(dateString)
Another Way is Also
DateTime dt = DateTime.Parse(strdate);
DateTime dtDate = Convert.ToDateTime(strDate);
"Convert" is a class in a "System" namespace.
This thread is for discussions of How to convert a string to a date.