Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Wednesday, November 11, 2026
About Us
Magazine
Open Source
CVS
Services
Index  »  Projects  »  phpMyEdit  »  Forum  »  Date reformatting error

phpMyEdit General     Date reformatting error
Post new topic   Reply to topic    
 
Ivo     Joined: 03 Jun 2004   Posts: 10  
Post Posted: 2004-07-30 16:30
Back to top  Reply with quote     

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

Code:
$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:

Quote:
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     Joined: 17 Dec 2003   Posts: 236  
Post Posted: 2004-07-30 18:56
Back to top  Reply with quote     

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:
Code:

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


 
Ivo     Joined: 03 Jun 2004   Posts: 10  
Post Posted: 2004-08-02 15:44
Back to top  Reply with quote     

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     Joined: 17 Dec 2003   Posts: 236  
Post Posted: 2004-08-03 10:02
Back to top  Reply with quote     

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

 
Ivo     Joined: 03 Jun 2004   Posts: 10  
Post Posted: 2004-08-03 13:43
Back to top  Reply with quote     

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     Joined: 03 Jun 2004   Posts: 10  
Post Posted: 2004-08-03 14:06
Back to top  Reply with quote     

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. :)

 
Post new topic   Reply to topic    

Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top · Feedback form · Application form
Report bug on PLATON.SK website · Terms of use · Privacy policy