I have the string "8/2/2007 12:00:00 AM"
I'd like to get this in DateTime variable so I can manipulate (e.g.
use TimeSpan to find difference). However, when I look at the
DateTime constructors, everything seems to be int, long, etc.
So my question is, what would be the easiest way to get this into
DateTime? Seems like a long way would be to split at the "/", parse
out, use int.Parse, etc (brute force). But I was wondering if there
was a quick and cleaver way to do this in minimal lines of code?
Thanks- Yin
background info: i'm using DateTimePicker control and reading the
value which returns a string in format above. I have two
DateTimePickers and need to know the number of months between the
value in the first DateTimePicker and the second DateTimePicker. 3 1325
Yin99 wrote:
I have the string "8/2/2007 12:00:00 AM"
I'd like to get this in DateTime variable so I can manipulate (e.g.
use TimeSpan to find difference). However, when I look at the
DateTime constructors, everything seems to be int, long, etc.
So my question is, what would be the easiest way to get this into
DateTime? Seems like a long way would be to split at the "/", parse
out, use int.Parse, etc (brute force). But I was wondering if there
was a quick and cleaver way to do this in minimal lines of code?
Thanks- Yin
background info: i'm using DateTimePicker control and reading the
value which returns a string in format above. I have two
DateTimePickers and need to know the number of months between the
value in the first DateTimePicker and the second DateTimePicker.
I think the following code will work:
Dim d As DateTime
d = Date.Parse("8/2/2007 12:00:00 AM")
Cheers,
RB.
if it's truely a DateTime variable, all DateTime members should be available
to you.
could you show us your code?
David Wier http://aspnet101.com http://iWritePro.com
"Yin99" <ws@ziowave.comwrote in message
news:11**********************@57g2000hsv.googlegro ups.com...
>I have the string "8/2/2007 12:00:00 AM"
I'd like to get this in DateTime variable so I can manipulate (e.g.
use TimeSpan to find difference). However, when I look at the
DateTime constructors, everything seems to be int, long, etc.
So my question is, what would be the easiest way to get this into
DateTime? Seems like a long way would be to split at the "/", parse
out, use int.Parse, etc (brute force). But I was wondering if there
was a quick and cleaver way to do this in minimal lines of code?
Thanks- Yin
background info: i'm using DateTimePicker control and reading the
value which returns a string in format above. I have two
DateTimePickers and need to know the number of months between the
value in the first DateTimePicker and the second DateTimePicker.
Yin99 wrote:
I have the string "8/2/2007 12:00:00 AM"
I'd like to get this in DateTime variable so I can manipulate (e.g.
use TimeSpan to find difference). However, when I look at the
DateTime constructors, everything seems to be int, long, etc.
So my question is, what would be the easiest way to get this into
DateTime? Seems like a long way would be to split at the "/", parse
out, use int.Parse, etc (brute force). But I was wondering if there
was a quick and cleaver way to do this in minimal lines of code?
Thanks- Yin
background info: i'm using DateTimePicker control and reading the
value which returns a string in format above. I have two
DateTimePickers and need to know the number of months between the
value in the first DateTimePicker and the second DateTimePicker.
Try out DateTime.ParseExact(...) http://msdn2.microsoft.com/en-us/library/w2sa9yss.aspx
HTH,
Petar Atanasov http://a-wake.net This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: PK9 |
last post by:
I have a string variable that holds the equivalent of a DateTime value. I
pulled this datetime from the database and I want to strip off the time
portion before displaying to the user.
I am...
|
by: Sterling Ledet |
last post by:
I am trying to create a web service that takes a string from my web server
in the following format:
Mon, 6 Oct 2003 18:39:47 UTC
and put's in a datetime so it can then be reformatted in C# as...
|
by: nobody |
last post by:
I know that given a FormatString and a DateTime you can use
DateTime.ToString(...) to convert the DateTime to a String. My question is
how can you turn that around? Given a String and a...
|
by: genc_ymeri |
last post by:
Hi over there,
Propably this subject is discussed over and over several times. I did google
it too but I was a little bit surprised what I read on internet when it
comes 'when to use what'.
Most...
|
by: morleyc |
last post by:
Hi, i would like to remove a number of characters from my string (\t
\r \n which are throughout the string), i know regex can do this but i
have no idea how. Any pointers much appreciated.
Chris
| |
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |