Connecting Tech Pros Worldwide Forums | Help | Site Map

Determining whether a string is a date, time, or date and time

Nathan Sokalski
Guest
 
Posts: n/a
#1: Mar 27 '08
When determining whether a String can be converted to a DateTime, you can
use the IsDate() method. However, I would also like to know whether the
string is a date, a time, or both a date and a time. Is there any simple way
to do this without using manual pattern matching? Thanks.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/



Spam Catcher
Guest
 
Posts: n/a
#2: Mar 27 '08

re: Determining whether a string is a date, time, or date and time


"Nathan Sokalski" <njsokalski@hotmail.comwrote in
news:O8ULZv5jIHA.4376@TK2MSFTNGP04.phx.gbl:
Quote:
When determining whether a String can be converted to a DateTime, you
can use the IsDate() method. However, I would also like to know
whether the string is a date, a time, or both a date and a time. Is
there any simple way to do this without using manual pattern matching?
Thanks.
Perhaps you can use the Convert.ToDate() function? Once you convert it to a
date, you can check the .Date and .Time properties to determine the
original values?



--
spamhoneypot@rogers.com (Do not e-mail)
Nathan Sokalski
Guest
 
Posts: n/a
#3: Mar 27 '08

re: Determining whether a string is a date, time, or date and time


This would not work. The reason I need to know this information is so that I
know whether to include the date, time, or both when submitting the data to
a database. The reason your suggestion will not work is because a Date
object ALWAYS has a date and time, even if the date is the default date or
the time is 0:00 or 12:00 or whatever. Therefore, looking at these parts of
the Date will tell me nothing about whether a date, time, or both were
included in the original String.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

"Spam Catcher" <spamhoneypot@rogers.comwrote in message
news:Xns9A6DDD5D7857Ausenethoneypotrogers@127.0.0. 1...
Quote:
"Nathan Sokalski" <njsokalski@hotmail.comwrote in
news:O8ULZv5jIHA.4376@TK2MSFTNGP04.phx.gbl:
>
Quote:
>When determining whether a String can be converted to a DateTime, you
>can use the IsDate() method. However, I would also like to know
>whether the string is a date, a time, or both a date and a time. Is
>there any simple way to do this without using manual pattern matching?
>Thanks.
>
Perhaps you can use the Convert.ToDate() function? Once you convert it to
a
date, you can check the .Date and .Time properties to determine the
original values?
>
>
>
--
spamhoneypot@rogers.com (Do not e-mail)

Cor Ligthert[MVP]
Guest
 
Posts: n/a
#4: Mar 27 '08

re: Determining whether a string is a date, time, or date and time


Nathan,

Just creating a different box for the date and time string makes things a
lot easier.
Especially on a website where this is even more common.

There are in different cultures two kind of clock registrations used.

With an 24 hour clock and a 12 hour clock even about this you have to take
care of.

Cor

Patrice
Guest
 
Posts: n/a
#5: Mar 27 '08

re: Determining whether a string is a date, time, or date and time


Which DB are you using ? It also has a default time anyway so even if you
don't include a time part it will have a default time part server side ?

"Nathan Sokalski" <njsokalski@hotmail.coma écrit dans le message de news:
%23G7$bA7jIHA.1204@TK2MSFTNGP03.phx.gbl...
Quote:
This would not work. The reason I need to know this information is so that
I know whether to include the date, time, or both when submitting the data
to a database. The reason your suggestion will not work is because a Date
object ALWAYS has a date and time, even if the date is the default date or
the time is 0:00 or 12:00 or whatever. Therefore, looking at these parts
of the Date will tell me nothing about whether a date, time, or both were
included in the original String.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/
>
"Spam Catcher" <spamhoneypot@rogers.comwrote in message
news:Xns9A6DDD5D7857Ausenethoneypotrogers@127.0.0. 1...
Quote:
>"Nathan Sokalski" <njsokalski@hotmail.comwrote in
>news:O8ULZv5jIHA.4376@TK2MSFTNGP04.phx.gbl:
>>
Quote:
>>When determining whether a String can be converted to a DateTime, you
>>can use the IsDate() method. However, I would also like to know
>>whether the string is a date, a time, or both a date and a time. Is
>>there any simple way to do this without using manual pattern matching?
>>Thanks.
>>
>Perhaps you can use the Convert.ToDate() function? Once you convert it to
>a
>date, you can check the .Date and .Time properties to determine the
>original values?
>>
>>
>>
>--
>spamhoneypot@rogers.com (Do not e-mail)
>
>

Closed Thread