Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Streda, 25. november 2026
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  Date reformatting error

phpMyEdit General     Date reformatting error
Odoslať novú tému   Odpovedať na tému    
 
Ivo     Založený: 03.06.2004   Príspevky: 10  
Príspevok Zaslal: 2004-07-30 16:30
Návrat hore  Odpovedať s citátom     

In relation to the date format (YYYY-MM-DD versus DD-MM-YYYY) problem, why doesn't this work:

Kód:
$opts['fdd']['datum']['sqlw'] =
    "CONCAT_WS('-'," .
      "SUBSTRING_INDEX(datum,'-',-1), " .
      "SUBSTRING_INDEX( SUBSTRING_INDEX(datum,'-',2),'-',-1 ), " .
      "SUBSTRING_INDEX(datum,'-', 1) ".
    ")";


I get this error:

Citácia:
MySQL error 1064
You have an error in your SQL syntax near '(datum,'-',2),'-',-1 ), SUBSTRING_INDEX(datum,'-', 1) ), '1', '', 'a', 'b', '1',' at line 1


Don't tell me I can't use return values from functions in other functions from sqlw! :(

I need a datemask for writes![/quote]

 
ajh     Založený: 17.12.2003   Príspevky: 236  
Príspevok Zaslal: 2004-07-30 18:56
Návrat hore  Odpovedať s citátom     

Suggestion...use the STR_TO_DATE function. It takes a string and date format and turns the string into a date based on the format...much easier.

Reference here: http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html

BTW the reason it doesn't work is that you can't use column names like that in an 'sqlw' clause. You should use $val or one of the variations as your variable - see the page in the PME manual: http://opensource.platon.sk/projects/doc.php/phpMyEdit/html/configuration.fields.sql.html

I think that your whole expression should be:
Kód:

['sqlw'] = 'STR_TO_DATE($val_qas, "%Y-%m-%d")'


 
Ivo     Založený: 03.06.2004   Príspevky: 10  
Príspevok Zaslal: 2004-08-02 15:44
Návrat hore  Odpovedať s citátom     

I don't have MySQL 4.1.1 here right now, but oh well. I'll try the $val thing; I knew this, but I think I saw an example in the docs using column namees. Guess not, then. Thanks for the help.

 
ajh     Založený: 17.12.2003   Príspevky: 236  
Príspevok Zaslal: 2004-08-03 10:02
Návrat hore  Odpovedať s citátom     

STR_TO_DATE is not new in 4.1.1. It should work in earlier version of MySQL.

 
Ivo     Založený: 03.06.2004   Príspevky: 10  
Príspevok Zaslal: 2004-08-03 13:43
Návrat hore  Odpovedať s citátom     

Well, it says so in the MySQL reference guide:

STR_TO_DATE() is available as of MySQL 4.1.1.

Also, it doesn't work on my MySQL version 3.23.58. And I copy & pasted the example code from the manual into the mysql client to test it.

 
Ivo     Založený: 03.06.2004   Príspevky: 10  
Príspevok Zaslal: 2004-08-03 14:06
Návrat hore  Odpovedať s citátom     

Aaaaagh!!

Can you believe that it didn't work the whole time because of a SPACE between SUBSTRING_INDEX and the ( next to it!? (The quoted code doesn't have this) I hate myself!

It works fine now. :)

 
Odoslať novú tému   Odpovedať na tému    

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov