473,545 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checking for Valid Date

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 even allowing this. But anyway, my question
is, what is the best way to validate a Foxpro "date" in VB.Net as I read it
in from VFP and before I insert it into SQL Server?

I have several thoughts but wanted to see what all you experts think.

TIA...
--
Thanks,

Scott
Nov 21 '05 #1
4 4596
"=?Utf-8?B?U1FMU2NvdHQ =?=" <SQ******@discu ssions.microsof t.com> wrote in
news:6D******** *************** ***********@mic rosoft.com:
'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 even allowing this. But
anyway, my question is, what is the best way to validate a Foxpro
"date" in VB.Net as I read it in from VFP and before I insert it into
SQL Server?

I have several thoughts but wanted to see what all you experts think.


Check if the year is less than 1753. If so, throw an error.

This may work for checking for the year:

Year(CDate("08/08/0997 12:00:00 PM"))
SQL DateTime Reference:
http://msdn.microsoft.com/library/de...l=/library/en-
us/tsqlref/ts_da-db_9xut.asp

Nov 21 '05 #2
Hi Scott,

The earliest date FoxPro can record is 1/1/100, so 8/8/0997 is a legal date
for FoxPro data. The back of my mind is why SQL Server is so limited in the
dates it can record. :-)

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
ci************* *@mvps.org www.cindywinegarden.com
"SQLScott" <SQ******@discu ssions.microsof t.com> wrote in message
news:6D******** *************** ***********@mic rosoft.com...
'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 even allowing this. ....

Nov 21 '05 #3
Hi Cindy,

The earliest date FoxPro can record is 1/1/100, so 8/8/0997 is a legal date for FoxPro data. The back of my mind is why SQL Server is so limited in the dates it can record. :-)


It is real strange when you think that you can add dates until 9999.
Therefore when I have a date before 1800 I add 2000 and subtract that when
the date is more in future than 3000 by reading.

They have not looked back, however far far in future. It should be very
optimistic guys who made it, because it has of course to be used much longer
than Foxpro.

:-)

Cor
Nov 21 '05 #4
Says who? :-)

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
ci************* *@mvps.org www.cindywinegarden.com
"Cor Ligthert" <no**********@p lanet.nl> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
it has of course to be used much longer than Foxpro.

Nov 21 '05 #5

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

Similar topics

8
2741
by: John V | last post by:
What kind of regular expression pattern is needed to check if URL is valid? It's enought if most of cases are covered. I have PHP 4.x. Br
7
7561
by: - ions | last post by:
I have created a JComboBox with its Items as a list of "M" numbers ie. M1,M2,M3.......throgh too M110 (thes are the messier objects, a catolouge of deep sky objects) the user selects of of these and views it aswell as infomation. The program also has a JTextFiels which allows the user to enter the M number. The problem i have is checking that...
67
4196
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. Unfortunately these ad hominem rhetorts are frequently introduced into purely technical discussions on the feasibility of supporting such functionality in C++....
11
33293
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"
28
2004
by: romy | last post by:
What's the easiest way to verify the user had entered a valid date ?
4
2351
by: Patient Guy | last post by:
Does anyone have any coding rules they follow when doing argument checking? When arguments fail during check, do you return from the call with an ambiguous return value, or do you throw exceptions?
17
5243
by: Petyr David | last post by:
Just looking for the simplest. right now my perl script returns an error messge to the user if the date string is invalid. would like to do this before accessing the server. TX
7
14167
by: kannushree | last post by:
i have built a program ,that checks wheteher a date is valid or not. now if i want to add date,month year (in same input) to a particular date,,how wud the logic work? it should be like dis : void add(int d, int m,int y)
6
2125
by: Mike P | last post by:
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.ToDateTime would work even if a time is not added so I can't use this? *** Sent via Developersdex http://www.developersdex.com ***
0
7420
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...
0
7680
Oralloy
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. ...
1
7446
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...
0
7778
tracyyun
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...
0
6003
agi2029
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...
1
5349
isladogs
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...
0
4966
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...
0
3459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
731
bsmnconsultancy
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...

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.