473,699 Members | 2,273 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 4603
"=?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
2761
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
7580
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 what the user has entered is valid, that being an M followed by 1 - 110 Nothing else, i thought of...
67
4258
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++. That usually serves to divert the discussion from the technical subject to a discussion of the...
11
33318
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
2025
by: romy | last post by:
What's the easiest way to verify the user had entered a valid date ?
4
2381
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
5275
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
14192
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
2134
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
8706
marktang
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, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
8631
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9055
jinu1996
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...
0
5889
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();...
0
4392
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4641
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3075
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
2
2366
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2016
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.