Date comparison in a text data field

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Date comparison in a text data field

    I have a database column field defined as a text. I store dates in format:
    dd/mm/yyyy.

    The user passes a Start date search string in the same format. I need to
    filter for dates larger or equal then this string. Can this be done?

    Thanks!

    The db system i use is PostgreSQL with MX 7

    Ad Bec Guest

  2. Similar Questions and Discussions

    1. Outputting data using date field
      I have a query that outputs the result based on date. I m writing it as: select * from apna where assignedto='#form.assignedto#' and...
    2. Date text Field
      I have an asp form that is submitted to sql server 2000. There are three date fields. How can I allow the user to enter the date without any...
    3. Converting a text field to a date field - FM6
      I need to convert a Text field containing both auto and manually entered dates over to a Date field. The records that were autoentered move over...
    4. Linking date field to text field entry
      Is there a way to setup a date field that will automatically enter the date when any information is entered into a field next to it?
    5. date in text field
      How can I include a date that is formatted in the following structure 9-July-03, and include it in a form text field? The form input code is:...
  3. #2

    Default Re: Date comparison in a text data field

    Yes, with string functions. It would be easier if you stored dates as dates, but you don't.
    Dan Bracuk Guest

  4. #3

    Default Re: Date comparison in a text data field

    Hi,

    thanks for the answer Dan, Can you please tell me how can it be done with
    string functions?

    Here and example of the table:
    ListingsSectionsSelectedValues.SectionCustomValue >= '28/12/2005'

    Thanks for your help!

    Ad Bec Guest

  5. #4

    Default Re: Date comparison in a text data field

    I agree that it would be much better to store the date values in a date/time
    column. Have you tried simply casting the column as a date/time in your query?
    I don't know the correct syntax for PostgreSQL, but something like

    WHERE CAST(yourColumn AS datetime) >= (some date value)


    mxstu Guest

  6. #5

    Default Re: Date comparison in a text data field

    I don't know postrgresql, but, what you have to do is re-arrange your string to
    yyyymmdd. To do that in Cold fusion with the user input is simple -
    x =right(date, 4) & mid(date, 3, 2) & left(date, 2);

    If you can't do something similar in your database, you just put

    where (your postgresql function stuff) < '#x#'

    Otherwise, you could always select all rows (hope there are not that many,
    loop though and rearrange the field using querysetcell and do a Q of Q. It
    wouldn't be efficient, but it would get your answer.



    Originally posted by: Ad Bec
    Hi,

    thanks for the answer Dan, Can you please tell me how can it be done with
    string functions?

    Here and example of the table:
    ListingsSectionsSelectedValues.SectionCustomValue >= '28/12/2005'

    Thanks for your help!



    Dan Bracuk Guest

  7. #6

    Default Re: Date comparison in a text data field

    >To do that in Cold fusion with the user input is simple -
    >x =right(date, 4) & mid(date, 3, 2) & left(date, 2);
    Just a small correction. It should be:

    x =right(date, 4) & mid(date, 4, 2) & left(date, 2);



    mxstu Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139