extract data between certain date.

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

  1. #1

    Default extract data between certain date.

    Hi all. I have a data base with purchases. Now i am trying to write a report
    page to allow me to see what has been bougth between certain dates. I have 3
    select html forms. one for year #form.startyear# one for the month
    #form.startmonth# and one for day #form.startday# i have then 3 more which are
    #form.endyear#, #form.endmonth# and #form.endday#. how could i use coldfusion
    for this report.

    maybe something like... this is all new to me so any help would be
    appreciated....




    <cfset StartDate = #form.startyear#, #form.startmonth# and #form.startday#>
    <cfset EndDate = #form.endyear#, #form.endmonth# and #form.endday#>

    <cfquery name="test456" datasource="test">
    SELECT *
    From purchases
    WHERE ((purchases.testDate BETWEEN #CreateODBCDate(StartDate)# AND
    #CreateODBCDate(EndDate)#))
    ORDER BY Name
    </cfquery>

    Samurai_Sjakkie Guest

  2. Similar Questions and Discussions

    1. Extract Data from PDF
      Does anyone make a plug-in that would extract info from a PDF for use as a file name? We receive about 50 pdf's each evening, copies of invoices,...
    2. extract data with csv format
      Hi.. could anyone tell me how do I have the data in csv format, so whenenver i click at the lick and dreamweaver page will save the file as csv to c...
    3. extract a date from a string
      I'm trying to figure out a way to extract dates from a string of any length using strtotime. strtotime only works if the date is formatted to GNU...
    4. Extract most recent price reduction and date in series of fields in same row
      If one has a series of price reduction fields (3) and corresponding date fields (3) in each record.....how would one check the row to see which of...
    5. Extract most recent price reduction and date in serie
      Hi - this post overlaps with another post (Tom K was helping) but has a differnt slant and explanation which I feel warrants a new post..... If...
  3. #2

    Default Re: extract data between certain date.

    First of all, using 3 selects in your form enables users to send you values
    like Feb 31 which is not a valid date. You'll have to validate your the
    submission before you do anything.

    Assuming you have done that, things would be simpler to envision if you have
    leading zero's in your month and day fields. If you didn't handle that in your
    form, use numberformat() to do do it on your processing page. Then you can do
    this

    <cfset startdate = createodbcdate(form.startyear & "-" & form.startmonth & "-"
    & form.startday)>

    same thing for enddate.

    in your query you don't need all those brackets.

    where purchases.testdate between StartDate and EndDate

    Dan Bracuk Guest

  4. #3

    Default Re: extract data between certain date.

    sorry its all a bit confusing.
    so it is

    <cfset startdate = createodbcdate(form.startyear & "-" & form.startmonth & "-"
    & form.startday)>
    <cfset enddate = createodbcdate(form.endyear & "-" & form.endmonth & "-" &
    form.endday)>

    <cfquery name="test456" datasource="test">
    SELECT *
    From purchases
    where #purchases.testdate# between #StartDate# and #EndDate#
    ORDER BY Name
    </cfquery>

    what if i have an "all" option within the #form.startyear# and#from.endyear#
    which has a value of "0" could i run something to check for this first and
    report all the purchases and if it hasn't been selected that it does the above
    query.

    My apologies, i suffer from learning difficulties.

    Samurai_Sjakkie 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