You are here: Re: date mystery « PHP Programming Language « IT news, forums, messages
Re: date mystery

Posted by meltedown on 12/02/58 11:28

Oli Filth wrote:
> meltedown said the following on 04/10/2005 18:40:
>
>> Steve wrote:
>>
>>>> Why doesn't this return anything ?
>>>>
>>>> SELECT DATE_SUB('FROM_DAYS(TO_DAYS(2005-09-28 18:04:19))', INTERVAL
>>>> 6 DAY)
>>>
>>>
>>>
>>>
>>> Uh. Dunno. What are you typing it into? What language do you think it
>>> is? It looks a bit like a MySQL query, but mangled; is that what you
>>> intended? If it is, why are there single quotes around the first
>>> argument to DATE_SUB()? Is there another DATE_SUB() that expects a
>>> string rather than a date? Yes, it's definitely a mystery...
>>>
>>>
>> Its mysql.
>>
>> If I take the quotes out, I get an error
>>
>>
>> query failed:1064: You have an error in your SQL syntax; check the
>> manual that corresponds to your MySQL server version for the right
>> syntax to use near '18:04:19)), INTERVAL 6 DAY)' at line 1
>>
>> query was:
>> SELECT DATE_SUB(FROM_DAYS(TO_DAYS(2005-09-28 18:04:19)), INTERVAL 6 DAY)
>>
>> I'm trying to get the date that's a week before the date in the query.
>
>
> If you had bothered to RTFM, you would've found that you can put the
> date straight into DATE_SUB (seeing as FROM_DAYS(TO_DAYS()) gets you
> back where you started, assuming you had the syntax correct).

I've tried to read the date functions section but it is written in
neo-colonial greek. That's early greek, before Athens was even a city.
I've got all the best books, and they aren't much better.
>
> Note also that a week is 7 days long!
>
> SELECT DATE_SUB('2005-09-28 18:04:19', INTERVAL 7 DAY)
>
> If you don't want the time in the result, then cast it to a DATE, i.e.:
>
> SELECT DATE(DATE_SUB('2005-09-28 18:04:19', INTERVAL 7 DAY))
>
>
Thanks, that seems to work. The other worked for a long time, I don't
know why it would work and then not work. The only thing different was
the date.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация