473,322 Members | 1,496 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,322 software developers and data experts.

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 4586
"=?Utf-8?B?U1FMU2NvdHQ=?=" <SQ******@discussions.microsoft.com> wrote in
news:6D**********************************@microsof t.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******@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.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**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP12.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
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
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...
67
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. ...
11
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 ...
28
by: romy | last post by:
What's the easiest way to verify the user had entered a valid date ?
4
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...
17
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
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...
6
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.