By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,230 Members | 2,471 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,230 IT Pros & Developers. It's quick & easy.

Checking for Valid Date

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
"=?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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.