473,379 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

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

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
nj********@hotmail.com
http://www.nathansokalski.com/
Mar 26 '08 #1
4 2087
"Nathan Sokalski" <nj********@hotmail.comwrote in
news:O8**************@TK2MSFTNGP04.phx.gbl:
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?

--
sp**********@rogers.com (Do not e-mail)
Mar 27 '08 #2
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
nj********@hotmail.com
http://www.nathansokalski.com/

"Spam Catcher" <sp**********@rogers.comwrote in message
news:Xn**********************************@127.0.0. 1...
"Nathan Sokalski" <nj********@hotmail.comwrote in
news:O8**************@TK2MSFTNGP04.phx.gbl:
>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?

--
sp**********@rogers.com (Do not e-mail)

Mar 27 '08 #3
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

Mar 27 '08 #4
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" <nj********@hotmail.coma écrit dans le message de news:
%2****************@TK2MSFTNGP03.phx.gbl...
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
nj********@hotmail.com
http://www.nathansokalski.com/

"Spam Catcher" <sp**********@rogers.comwrote in message
news:Xn**********************************@127.0.0. 1...
>"Nathan Sokalski" <nj********@hotmail.comwrote in
news:O8**************@TK2MSFTNGP04.phx.gbl:
>>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?

--
sp**********@rogers.com (Do not e-mail)


Mar 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Joshua Beall | last post by:
Hi All, I am wondering what the best way to determine an age of something/somone is. For instance, let's say I have two dates: 1985-07-19 2003-11-30 Now, I want to determine the interval...
12
by: Cliff Wells | last post by:
Hi, I'm writing an application that needs to know if an Internet connection is available. Basically, I want to have something similar to what a lot of email clients have, where the app can work...
6
by: HateSpam | last post by:
I am trying to write a function that determines how many hours there are until a certain date/time that depends on what today's date/time is. Basically, how many hours from now until the next...
1
by: Susan Bricker | last post by:
Greetings. I am trying to position opened forms so that they are cascaded on the screen. I have discovered the movesize action (for the DoCmd) and Move property of a form (for Acc 2002/2003). ...
4
by: Keith Patrick | last post by:
I have a web page that has a bunch of usercontrols, each declaring a Button called "GoButton". Now, my parent page has to be able to determine which button triggered the event. The catch is: I'd...
9
by: cj | last post by:
I'm reading a file line by line using line = StreamReader.ReadLine and normally I Do While Not line = Nothing But, this file has a lot of blank lines. How do I determine if I'm at the...
2
by: pob | last post by:
I was all happy because thru some tutelage of others I created this array to find the newest file in a directory. However, I then realized its great that I now know the latest file, but I need to...
1
by: FrankEBailey | last post by:
Hi, I have a limited number of ad slots on my website, let's say there are 5. I have lots of people wanting to advertise in those slots, let's say there are 100. They each join the queue for an...
14
by: dascandy | last post by:
Hi, I was wondering, is it possible to determine whether a string can be modified (const char *) by the application or whether it's located in what's commonly .rodata? Regards, Peter
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.