Hi Every one
Need some help to Validate the Date i have in the Form.
ALso how to Convert the Date Data i read from table to yyyy/MMM/dd format.
Thanks
RSB 6 1975
You can validate a date using Regular Expressions. It is, by far the easiest
way with validation controls. To validate back end, you can also attempt to
cast into a DateTime structure and see if it blows up. While this may seem a
bit strange, the regex to correctly test for months of different lengths
would be rather large. The DateTime object will guarantee 2/29/2005 does not
slip in.
As far as date formatting, this is most easily changed using CultureInfo
objects and setting culture to a country that uses the date format you wish
to use. The other option is to rip the date apart, by parts, and reorder.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
*************** *************** *************** ***
Think Outside the Box!
*************** *************** *************** ***
"RSB" <rs*****@hotmai l.com> wrote in message
news:YK******** ********@news.c pqcorp.net... Hi Every one
Need some help to Validate the Date i have in the Form. ALso how to Convert the Date Data i read from table to yyyy/MMM/dd format.
Thanks
RSB
You can use the CompareValidato r as well. Set the Operator property to
DataTypeCheck and set the Type property to Date.
-John Oakes
"Cowboy" <No************ @comcast.netNoS pamM> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. .. You can validate a date using Regular Expressions. It is, by far the
easiest way with validation controls. To validate back end, you can also attempt
to cast into a DateTime structure and see if it blows up. While this may seem
a bit strange, the regex to correctly test for months of different lengths would be rather large. The DateTime object will guarantee 2/29/2005 does
not slip in.
As far as date formatting, this is most easily changed using CultureInfo objects and setting culture to a country that uses the date format you
wish to use. The other option is to rip the date apart, by parts, and reorder.
-- Gregory A. Beamer MVP; MCP: +I, SE, SD, DBA
*************** *************** *************** *** Think Outside the Box! *************** *************** *************** *** "RSB" <rs*****@hotmai l.com> wrote in message news:YK******** ********@news.c pqcorp.net... Hi Every one
Need some help to Validate the Date i have in the Form. ALso how to Convert the Date Data i read from table to yyyy/MMM/dd
format. Thanks
RSB
Here yer go ... as recommended by Cowboy, and cut'n'paste directly from an
app I'm writing.
The first test is for an ordinary date, explicitly coded to en-GB 'cos
browsers don't appear to return the right nationality and this is for UK.
The second test is because the users are occasionally lazy about 4 digit
years, the third test allows for year only entry - a requirement of the app
I'm writing, and the fourth test is just getting fancy; nobody will ever
type the word "today" into a text box. To parse other date formats simply
add more tests.
Cheers
Richard
_______________ _______________ _______________
Dr. Richard Petheram
AdlZ Ltd.
E-mail: richard_at_adlz .co.uk
_____________We b: www.adlz.co.uk ____________
[ CODE FOLLOWS ]
Public Shared Function ParseDate(ByVal pString As String, Optional ByRef
IsValid As Boolean = True) As DateTime
Dim lDTF As DateTimeFormatI nfo =
CultureInfo.Cre ateSpecificCult ure("en-GB").DateTimeFo rmat
Dim lResult As DateTime
Try
lResult = DateTime.Parse( pString, lDTF).Date
IsValid = True
Return lResult
Catch ex As Exception
End Try
Try
lResult = DateTime.ParseE xact(pString, "dd/MM/yy", lDTF).Date
IsValid = True
Return lResult
Catch ex As Exception
End Try
Try
lResult = DateTime.ParseE xact(pString, "yyyy", lDTF).Date
IsValid = True
Return lResult
Catch ex As Exception
End Try
If pString.Trim.To Lower = "today" Then
lResult = DateTime.Today. Date
IsValid = True
Return lResult
End If
IsValid = False
Return Nothing
End Function
[ END OF CODE ]
"Cowboy" <No************ @comcast.netNoS pamM> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. .. You can validate a date using Regular Expressions. It is, by far the
easiest way with validation controls. To validate back end, you can also attempt
to cast into a DateTime structure and see if it blows up. While this may seem
a bit strange, the regex to correctly test for months of different lengths would be rather large. The DateTime object will guarantee 2/29/2005 does
not slip in.
As far as date formatting, this is most easily changed using CultureInfo objects and setting culture to a country that uses the date format you
wish to use. The other option is to rip the date apart, by parts, and reorder.
-- Gregory A. Beamer MVP; MCP: +I, SE, SD, DBA
*************** *************** *************** *** Think Outside the Box! *************** *************** *************** *** "RSB" <rs*****@hotmai l.com> wrote in message news:YK******** ********@news.c pqcorp.net... Hi Every one
Need some help to Validate the Date i have in the Form. ALso how to Convert the Date Data i read from table to yyyy/MMM/dd
format. Thanks
RSB
Hi John,
so can i also set the Date format for the CompareValidato r???
Thanks
RSB
"John Oakes" <jo**@nospam.ne tworkproduction s.net> wrote in message
news:e%******** *******@TK2MSFT NGP10.phx.gbl.. .
You can use the CompareValidato r as well. Set the Operator property to
DataTypeCheck and set the Type property to Date.
-John Oakes
"Cowboy" <No************ @comcast.netNoS pamM> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. .. You can validate a date using Regular Expressions. It is, by far the
easiest way with validation controls. To validate back end, you can also attempt
to cast into a DateTime structure and see if it blows up. While this may seem
a bit strange, the regex to correctly test for months of different lengths would be rather large. The DateTime object will guarantee 2/29/2005 does
not slip in.
As far as date formatting, this is most easily changed using CultureInfo objects and setting culture to a country that uses the date format you
wish to use. The other option is to rip the date apart, by parts, and reorder.
-- Gregory A. Beamer MVP; MCP: +I, SE, SD, DBA
*************** *************** *************** *** Think Outside the Box! *************** *************** *************** *** "RSB" <rs*****@hotmai l.com> wrote in message news:YK******** ********@news.c pqcorp.net... Hi Every one
Need some help to Validate the Date i have in the Form. ALso how to Convert the Date Data i read from table to yyyy/MMM/dd
format. Thanks
RSB
Hi Richard,
thanks for the help.
So one question do you execute this code as a part of the Validation and
prompt an error message or it just check for the right error format...
"Richard Petheram" <rj*@adlz.co.uk > wrote in message
news:uL******** *******@newsfe1-gui.server.ntli .net...
Here yer go ... as recommended by Cowboy, and cut'n'paste directly from an
app I'm writing.
The first test is for an ordinary date, explicitly coded to en-GB 'cos
browsers don't appear to return the right nationality and this is for UK.
The second test is because the users are occasionally lazy about 4 digit
years, the third test allows for year only entry - a requirement of the app
I'm writing, and the fourth test is just getting fancy; nobody will ever
type the word "today" into a text box. To parse other date formats simply
add more tests.
Cheers
Richard
_______________ _______________ _______________
Dr. Richard Petheram
AdlZ Ltd.
E-mail: richard_at_adlz .co.uk
_____________We b: www.adlz.co.uk ____________
[ CODE FOLLOWS ]
Public Shared Function ParseDate(ByVal pString As String, Optional ByRef
IsValid As Boolean = True) As DateTime
Dim lDTF As DateTimeFormatI nfo =
CultureInfo.Cre ateSpecificCult ure("en-GB").DateTimeFo rmat
Dim lResult As DateTime
Try
lResult = DateTime.Parse( pString, lDTF).Date
IsValid = True
Return lResult
Catch ex As Exception
End Try
Try
lResult = DateTime.ParseE xact(pString, "dd/MM/yy", lDTF).Date
IsValid = True
Return lResult
Catch ex As Exception
End Try
Try
lResult = DateTime.ParseE xact(pString, "yyyy", lDTF).Date
IsValid = True
Return lResult
Catch ex As Exception
End Try
If pString.Trim.To Lower = "today" Then
lResult = DateTime.Today. Date
IsValid = True
Return lResult
End If
IsValid = False
Return Nothing
End Function
[ END OF CODE ]
"Cowboy" <No************ @comcast.netNoS pamM> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. .. You can validate a date using Regular Expressions. It is, by far the
easiest way with validation controls. To validate back end, you can also attempt
to cast into a DateTime structure and see if it blows up. While this may seem
a bit strange, the regex to correctly test for months of different lengths would be rather large. The DateTime object will guarantee 2/29/2005 does
not slip in.
As far as date formatting, this is most easily changed using CultureInfo objects and setting culture to a country that uses the date format you
wish to use. The other option is to rip the date apart, by parts, and reorder.
-- Gregory A. Beamer MVP; MCP: +I, SE, SD, DBA
*************** *************** *************** *** Think Outside the Box! *************** *************** *************** *** "RSB" <rs*****@hotmai l.com> wrote in message news:YK******** ********@news.c pqcorp.net... Hi Every one
Need some help to Validate the Date i have in the Form. ALso how to Convert the Date Data i read from table to yyyy/MMM/dd
format. Thanks
RSB
I don't think so. It seems to understand most formats though. I wouldn't
consider it a full-proof method to validate a date, but it works pretty well
depending on what your need is.
-John
"RSB" <rs*****@hotmai l.com> wrote in message
news:QV******** *******@news.cp qcorp.net... Hi John, so can i also set the Date format for the CompareValidato r???
Thanks RSB "John Oakes" <jo**@nospam.ne tworkproduction s.net> wrote in message news:e%******** *******@TK2MSFT NGP10.phx.gbl.. . You can use the CompareValidato r as well. Set the Operator property to DataTypeCheck and set the Type property to Date.
-John Oakes
"Cowboy" <No************ @comcast.netNoS pamM> wrote in message news:%2******** ********@TK2MSF TNGP10.phx.gbl. .. You can validate a date using Regular Expressions. It is, by far the easiest way with validation controls. To validate back end, you can also attempt to cast into a DateTime structure and see if it blows up. While this may
seem a bit strange, the regex to correctly test for months of different lengths would be rather large. The DateTime object will guarantee 2/29/2005 does not slip in.
As far as date formatting, this is most easily changed using CultureInfo objects and setting culture to a country that uses the date format you wish to use. The other option is to rip the date apart, by parts, and
reorder. -- Gregory A. Beamer MVP; MCP: +I, SE, SD, DBA
*************** *************** *************** *** Think Outside the Box! *************** *************** *************** *** "RSB" <rs*****@hotmai l.com> wrote in message news:YK******** ********@news.c pqcorp.net... Hi Every one
Need some help to Validate the Date i have in the Form. ALso how to Convert the Date Data i read from table to yyyy/MMM/dd format. Thanks
RSB
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Frank Rocco |
last post by:
Hello,
What is the best way to validate a textbox to see if it contains a valid
date or a valid time or both?
Thanks
Frank
|
by: Ali-R |
last post by:
Hi all,
I am getting a CSV file like this from our client:
"C1","2","12344","Mr","John","Chan","05/07/1976".........
I need to validate **each filed value** against a set of rules ,for instance
for "05/07/1976" ,I need to make sure that it's in the right format ,It's
not later than today and lots of other rules ,Is there somebody who can help
me how to that?Can I map it to some sort of xml schema or something?
|
by: James P. |
last post by:
Hello there,
In my asp.net page using VB, I have a date text field in mm/dd/yyyy
format. When a date is entered, I'd like to validate it to make sure
the date is greater than or equal to the current date. If not, I'd
like to display the error message to ValidationSummary.
It seems to make sense to me to use CompareValidator but the problem
is put the current date into CompareValidator. So, I created a hidden
text field in my aspx. ...
|
by: yoshitha |
last post by:
hi
db : sql server 2000
lan : C#.net(ASp.Net)
in my database table there are 2 fileds of data type datatime.
in field 1 i'm storing date
in field 2 i'm storing time.
|
by: Michel Posseth [MCP] |
last post by:
I have a problem with the date time picker validate event wich i believe is
a bug
How to reproduce :
throw on a form a date time picker control and a textbox control
select the validating event of the control and add this code
| |
by: pdesh3 |
last post by:
Hi,
I have a form in which 3 fileds are displayed on the top banner. They are DATE, NAME, LOCATION.
1. I want to make DATE filed dynamic where it whould read system date and display on it when ever I open that Form. I don't know what control to take for this whether LABEL or TEXTBOX.
|
by: samuelberthelot |
last post by:
Hello,
I would like to validate a date in a textbox on the onChange event.
The date must be in the format 01/01/2007
I would like to use a regular expression to validate it but I'm not
very familiar with them. How can I do it ?
Thanks
|
by: shapper |
last post by:
Hello,
What is the Regex expression to validate a date time format as
follows:
dd-mm-yyyy hh:mm:ss
An example:
20-10-2008 10:32:45
|
by: shawnmiller77 |
last post by:
Need Help ASAP!
History: Installed new SBS 2003 server on Monday. Migrated IIS, website and current Access database over to new server. I did not develop the website or Access database. Former IT guy is no where to be found. Everything is working on the new server except for one .asp page in the website that ties to the Access database. When I try and input data on the page and save it I receive the follwoing error:
Microsoft OLE DB...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |