Search code examples
foxpro

Comparing a date variable in FoxPro commandline


I would like to perform the following commands:

////accept to x ////display all for date_field=x

The purpose of these commands is to input a value x, after that I am going to display all the registers from a table whose date_field variable equals x The date_field has a variable of type (Date,8)

These date variables are stored like this for example: 03/11/17, 04/23/17 and so on. From keyboard, I am typing for example 03/11/17. Then, I try to compare, I got errors. Could someone tell me the right set of commands to perform this task?


Solution

  • If I understand it you are assigning a value that you have entered to a variable called 'x' and then using 'x' to compare against the date field.

    The problem is probably that 'x' is a string and you are trying to compare it to a date. So you need to use the ctod() function. For example:

    select * from mytable where date_field = ctod(x)
    

    Also be careful as to what your regional settings are.