Professional Web Applications Themes

bug (or not) on the curdate function ? - MySQL

Hi, I obtain a non-comprehensive result, when I execute a query with the curdate() function: select curdate() LIMIT 0,1 2007-01-03 -> OK select curdate() -2 LIMIT 0,1 20070101 -> OK, but a different format ? select curdate() -3 LIMIT 0,1 20070100 -> Arghhh!! Not OK At all !!!! What's wrong ? -- Jean-Paul...

  1. #1

    Default bug (or not) on the curdate function ?

    Hi,

    I obtain a non-comprehensive result, when I execute a query with the
    curdate() function:

    select curdate() LIMIT 0,1
    2007-01-03 -> OK

    select curdate() -2 LIMIT 0,1
    20070101 -> OK, but a different format ?

    select curdate() -3 LIMIT 0,1
    20070100 -> Arghhh!! Not OK At all !!!!

    What's wrong ?

    --
    Jean-Paul

    Jeanpaulik Guest

  2. #2

    Default Re: bug (or not) on the curdate function ?

    Jeanpaulik wrote:
     


    By performing math on it mysql will turn it into a number.


    --
    Brian Wakem
    Email: http://homepage.ntlworld.com/b.wakem/myemail.png
    Brian Guest

  3. #3

    Default Re: bug (or not) on the curdate function ?

    "Jeanpaulik" <com> wrote in message
    news:googlegroups.com... 

    You haven't told it what you are taking away. 2 Days? 2 Months? 2 Years?

    Try SELECT CURDATE() - INTERVAL 2 DAY


    Paul Guest

  4. #4

    Default Re: bug (or not) on the curdate function ?

    On Mon, 8 Jan 2007 14:32:06 -0000, Paul Lautman wrote: 
    >
    > You haven't told it what you are taking away. 2 Days? 2 Months? 2 Years?
    >
    > Try SELECT CURDATE() - INTERVAL 2 DAY[/ref]

    Exactly. The OP was basically forcing the date into being an integer
    scalar and then subtracting integer values of 2 and 3 from the integer
    20070103. Subtracting 10 would have gotten the result 20070093. Which
    would have, perhaps, been a bit more obvious about what was happening.

    --
    62. I will design fortress hallways with no alcoves or protruding structural
    supports which intruders could use for cover in a firefight.
    --Peter Anspach's list of things to do as an Evil Overlord
    Peter Guest

  5. #5

    Default Re: bug (or not) on the curdate function ?

    Yes, that's right !
    Thank you.

    On 8 jan, 15:32, "Paul Lautman" <com> wrote: 






    >
    > Try SELECT CURDATE() - INTERVAL 2 DAY[/ref]

    Jeanpaulik Guest

Similar Threads

  1. Replies: 5
    Last Post: June 27th, 02:12 AM
  2. Replies: 0
    Last Post: October 24th, 12:01 AM
  3. Replies: 0
    Last Post: October 14th, 04:28 PM
  4. Replies: 0
    Last Post: July 1st, 12:31 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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