469,362 Members | 2,505 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,362 developers. It's quick & easy.

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 4447
"=?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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by John V | last post: by
7 posts views Thread by - ions | last post: by
67 posts views Thread by Steven T. Hatton | last post: by
11 posts views Thread by Bob Day | last post: by
28 posts views Thread by romy | last post: by
4 posts views Thread by Patient Guy | last post: by
6 posts views Thread by Mike P | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.