How do I check for a valid datetime, where both the date and the time
must be entered in the format DD/MM/YYYY HH:MM? Using
Convert.ToDateT ime would work
even if a time is not added so I can't use this?
*** Sent via Developersdex http://www.developersdex.com *** 6 2128
"Mike P" <mi*******@gmai l.comwrote:
How do I check for a valid datetime, where both the date and the time
must be entered in the format DD/MM/YYYY HH:MM?
DateTime.ParseE xact.
I think your format string will be "dd/MM/yyyy HH:mm"
Eq.
Another approach; parse it, and then call ToString() specifying the
format you expected. If the "before" and "after" strings aren't the
same, then the input wasn't valid.
Marc
On Jun 3, 9:50 am, "Paul E Collins" <find_my_real_a ddr...@CL4.org>
wrote:
"Mike P" <mike.p...@gmai l.comwrote:
How do I check for a valid datetime, where both the date and the time
must be entered in the format DD/MM/YYYY HH:MM?
DateTime.ParseE xact.
Or DateTime.TryPar seExact for checking purposes.
I think your format string will be "dd/MM/yyyy HH:mm"
Agreed.
Jon
In this code example I have found, what classes do I need to reference
to get at DateTimeFormatI nfo and DateTimeStyles objects?
DateTime validatedDate;
bool valid = DateTime.TryPar seExact(date, date_format,
DateTimeFormatI nfo.InvariantIn fo, DateTimeStyles. None, out
validatedDate);
*** Sent via Developersdex http://www.developersdex.com ***
On Jun 3, 10:57 am, Mike P <mike.p...@gmai l.comwrote:
In this code example I have found, what classes do I need to reference
to get at DateTimeFormatI nfo and DateTimeStyles objects?
DateTime validatedDate;
bool valid = DateTime.TryPar seExact(date, date_format,
DateTimeFormatI nfo.InvariantIn fo, DateTimeStyles. None, out
validatedDate);
I think you mean the namespace - and System.Globaliz ation is what
you're after.
If you just write the code above though, and put the edit caret in
DateTimeStyles or DateTimeFormatI nfo, then hit Ctrl-period, it should
offer to import the right namespace for you. This can be a real time-
saver.
Jon
On Jun 3, 5:57*am, Mike P <mike.p...@gmai l.comwrote:
In this code example I have found, what classes do I need to reference
to get at DateTimeFormatI nfo and DateTimeStyles objects?
DateTime validatedDate;
bool valid = DateTime.TryPar seExact(date, date_format,
DateTimeFormatI nfo.InvariantIn fo, DateTimeStyles. None, out
validatedDate);
*** Sent via Developersdexht tp://www.developersd ex.com***
Hi,
If you want to know the namespace of a class all you have to do is
type it in MSDN lib, you will get it in the "About" section.
Those classes are in System.Globaliz ation BTW This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Maksim Kasimov |
last post by:
there are few of a time periods, for example:
2005-06-08 12:30 -> 2005-06-10 15:30,
2005-06-12 12:30 -> 2005-06-14 15:30
and there is some date and time value:
2005-06-11 12:30
what is the "pythonic" way to check is the date/time value in the given periods range?
something like xrange:
|
by: JackO |
last post by:
I have a text box on a form “txtExamDate” that I know contains nothing. I am
trying to test code that will determine the text box is nothing. I am
getting the error because there is no value in the field and I am assigning
it to a date field. My question is: How do I get the If statement to work?
Exception Details:...
|
by: andrewcw |
last post by:
I save date time into my XML files like this:
MesObj.theTime=System.DateTime.Now;
"5/4/2004 8:50:30 AM"
BUT that string is NOT recognizable as a valid
dateTime when the data is read back from file ( i.e. schema strong data type dateTime
It seems to follow this test protocal : DateTime transactDate = XmlConvert.ToDateTime(timeTest);
I...
|
by: William Stacey [MVP] |
last post by:
Given a day of the month (<=31) how to calculate if that day is valid for
all months up to some end date or DateTime.MaxValue? TIA
--
William Stacey, MVP
|
by: craigkenisston |
last post by:
Hi,
I create a one day ticket in my authentication code like this :
private void btnLogin_Click(object sender, System.EventArgs e)
{
string _userId = txtUserId.Text;
string _password = txtPassword.Text;
| |
by: SQLScott |
last post by:
I have created a VB.Net app that takes data from Visual Foxpro and inserts it
into SQL Server.
The problem I am running into is that I have come across records in Foxpro
where the dates are as follows:
'08/08/0997 12:00:00 PM'
Obviously, SQL Server does not accept 0997 as a valid date, and the back of
my mind is asking why is Foxpro...
|
by: Bob Day |
last post by:
The IsDate code below should result in False, instead it throws the
exception below. Why? How do I check if a string can be converted to a
date if this function does not work properly?
Bob
code:
Dim blnDate_Valid As Boolean = True
Dim x As String = "Hello"
|
by: romy |
last post by:
What's the easiest way to verify the user had entered a valid date ?
|
by: database |
last post by:
I AM FACING A PROBLEM WHEN I ACCESS ONE OF THE PAGES. IT USED TO WORK
BEFORE BUT AFTER RESTARTING THE APPLICATION SEVER IT GIVES THE FOLLOWING
ERROR.
- Server Error
--------------------------------------------------------------------------------
The string was not recognized as a valid DateTime. There is a unknown
word starting at...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |