RE: inserting a date variable into a foxpro db
am 17.06.2005 01:01:09 von JitGanguly
Probably its null or invalid date
Why not do some validation like
if isDate(request.form("inspectiontime")) Then
''"&request.form("inspectiontime")&"''
end if
"Theo" wrote:
> When inserting a new record I always seem to get a data type mismatch.
>
> Part of the code is
> ''"&request.form("inspectiontime")&"''
>
> my VFP field is a date..
>
> Please help.
>
> -----------------------------
> This message is posted by http://asp.forumszone.com
>
>
Re: inserting a date variable into a foxpro db
am 17.06.2005 19:21:16 von Cindy Winegarden
Hi Theo,
Your code fragment is a little too small to see what's going on. Be sure
you're sending a Date data type and not characters or a DateTime data type.
Also, in SQL Pass-through the way to represent a Date in a text string is to
surround it with curly brackets. There is an ordinary date such as
{06/17/2003}, but the day an month can be confused depending on your Windows
date settings. To be sure you've got a strict representation of the date use
curly brackets and a caret: {^2005/06/17}. Also, you can represent a date
with the FoxPro Date() function. Date() is today and Date(2005, 6, 18) is
tomorrow. Finally, there is a CtoD() function (Character To Date) which
looks like CtoD("06/17/2005"). This can be problematic for determining the
day and month. One more thing, Fox accepts single and double quotes, and
also square brackets as string delimiters. This is especially useful in SPT
when one of your values is a character string.
Here's some code examples:
strSQL = "Insert Into MyDateField Values ({^2005/06/18})"
strSQL = "Insert Into MyDateField Values (Date(2005, 6, 18))"
strSQL = "Insert Into MyDateField Values (CtoD([06/18/2005]))"
--
Cindy Winegarden MCSD, Microsoft Visual Foxpro MVP
cindy_winegarden@msn.com www.cindywinegarden.com
Blog: http://spaces.msn.com/members/cindywinegarden
"Theo" wrote in message
news:598565574839795@asp.forumszone.com...
> When inserting a new record I always seem to get a data type mismatch.
>
> Part of the code is
> ''"&request.form("inspectiontime")&"''
>
> my VFP field is a date..