Announcement

Collapse
No announcement yet.

database: extracting a date range?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    database: extracting a date range?

    i'm having a problem extracting a date range from the orders table in the database. am i right in saying that the field is stored as text?

    wtf?

    am i going loopy, or is that possibly the most daft way to store dates?

    has anyone got some sql that can ignore this little problem?

    #2
    Originally posted by gabrielcrowe
    has anyone got some sql that can ignore this little problem?
    I have some cans of Stella, Gabe...will that help?
    Tracey

    Comment


      #3
      lol, sadly, i only drink fine whiskey.

      Comment


        #4
        tsk...not a whiskey girl myself

        Stella or Vodka for me, I'm afraid..
        can't help then, sorry
        Tracey

        Comment


          #5
          You can just compare them

          ie: date1 > date2

          this is because they are stored backwards YYYYMMDD.

          Mines a G&T Tracey if you've got a spare one.

          Regards,
          Jan Strassen, Mole End Software - Plugins and Reports for Actinic V4 to V11, Sellerdeck V11 to V2018, Sellerdeck Cloud
          Visit our facebook page for the latest news and special offers from Mole End

          Top Quality Integrated label paper for Actinic and Sellerdeck
          A4 Paper with one or two peel off labels, free reports available for our customers
          Product Mash for Sellerdeck
          Link to Google Shopping and other channels, increase sales traffic, prices from £29.95
          Multichannel order processing
          Process Actinic, Sellerdeck, Amazon, Ebay, Playtrade orders with a single program, low cost lite version now available from £19.95

          Comment


            #6
            they arent stored in a comparable format.

            sql is unable to determine the relationsship between the items in a text based field.

            its fine, i did it script side, with little overhead.

            Comment


              #7
              Gabe,

              They are tmestamps, stored as yyyy/mm/dd hh:mm:ss

              Mine's a Talsiker - straight - about 4 fl oz should do it.
              Bill
              www.egyptianwonders.co.uk
              Text directoryWorldwide Actinic(TM) shops
              BC Ness Solutions Support services, custom software
              Registered Microsoft™ Partner (ISV)
              VoIP UK: 0131 208 0605
              Located: Alexandria, EGYPT

              Comment


                #8
                This is the first time I have to disagree with two people at once (and I don't like whisky either) sql can compare them as strings, the arrangement of the digits makes a string compare work for the dates, no problem and they are not stored as timestamps, take a look at the date ordered field in the order table, it's a string.

                Zoltan, mate ... come over here and agree with me (unless I'm wrong, then just igmore me).

                Regards,
                Jan Strassen, Mole End Software - Plugins and Reports for Actinic V4 to V11, Sellerdeck V11 to V2018, Sellerdeck Cloud
                Visit our facebook page for the latest news and special offers from Mole End

                Top Quality Integrated label paper for Actinic and Sellerdeck
                A4 Paper with one or two peel off labels, free reports available for our customers
                Product Mash for Sellerdeck
                Link to Google Shopping and other channels, increase sales traffic, prices from £29.95
                Multichannel order processing
                Process Actinic, Sellerdeck, Amazon, Ebay, Playtrade orders with a single program, low cost lite version now available from £19.95

                Comment


                  #9
                  But are we not talking about the Last Update field - which is a timestamp?
                  Bill
                  www.egyptianwonders.co.uk
                  Text directoryWorldwide Actinic(TM) shops
                  BC Ness Solutions Support services, custom software
                  Registered Microsoft™ Partner (ISV)
                  VoIP UK: 0131 208 0605
                  Located: Alexandria, EGYPT

                  Comment


                    #10
                    in the [order] table, my access tells me that the [Date Ordered] row is of type 'text'.

                    but even if mysql can compare the fields, it cant use 'between' for a field that isnt date, in the intra-year extraction of a date range.

                    for example, 1st december 06 to 31st january 07.

                    unless of course i'm utterly off the mark, and mssql can understand the format and ask for the range as dates anyhow.

                    if so, what sql do i use to extract the example date range?

                    Comment


                      #11
                      Ah, I had the wrong field.

                      Gabe - you would cast the Date Ordered field text content to a date type for the range comparison.
                      Bill
                      www.egyptianwonders.co.uk
                      Text directoryWorldwide Actinic(TM) shops
                      BC Ness Solutions Support services, custom software
                      Registered Microsoft™ Partner (ISV)
                      VoIP UK: 0131 208 0605
                      Located: Alexandria, EGYPT

                      Comment


                        #12
                        CAST();

                        my new best friend.

                        Comment


                          #13
                          Jan, I must disagree, the whiskey is fine. :-)
                          Zoltan
                          Actinic Software
                          www.actinic.co.uk

                          Comment


                            #14
                            can anyone give me an example of cast() in operation?

                            i cant for the life of me get it to work as it should.

                            PHP Code:
                            $sql "SELECT [Date Ordered], [Order Number] FROM [Order] WHERE CAST([Date Ordered] AS DATETIME) LIKE '#$fromday/$frommonth/$fromyear#' ORDER BY [Order Sequence Number] ASC;"
                            here is what *doesnt* work. this code should select a single day.

                            Comment


                              #15
                              game over: the access db engine does not support the cast() method. and there is no way to convert type from the jet/odbc interface in php.

                              that i can find.

                              Comment

                              Working...
                              X