What are the possible reasons that you "need it to be a varchar" ?? Do you realize how much extra work you are creating for yourself? Do you realize that you can have your users enter data in one format, and convert it to another format for MySQL? Do you realize you can use DATE_FORMAT() in your query to re-format the date back to dd-mm-YYYY if you want to? Do you realize that if you ever wanted to sort by this column, you'd be all messed up? It'll sort as a string, where "10" is less than "2". Do you realize what I'm trying to say??
---John Holmes... > -----Original Message----- > From: Andre Dubuc [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, June 12, 2002 8:15 PM > To: Lazor, Ed > Cc: [EMAIL PROTECTED] > Subject: Re: [PHP] Extracting from an Array > > Thanks Ed, > > Slight change -- I forgot that the delimiter was a 'space'. Anyway, I > still > get the first letter of the last part of the array. I guess what I need is > something that specifies a range as in something like this: > > $Year = $Date[3-whatever?]; > > Seems rather odd that with the string as varchar it does this. I've no > problem extracting various parts of a date from type 'date' but this wierd > date-thingy. . . how I wish I didn't need it as varchar. > > Anyway, thanks -- I plug away at it. > > Regards, > Andre > > > On Wednesday 12 June 2002 07:09 pm, you wrote: > > $sql = "select fieldname from tablename"; > > $Results = mysql_query($sql, $DBLink); > > $Row = mysql_fetch_array($Results); > > $fieldname = $Row["fieldname"]; > > $Date = explode("-", $fieldname); > > $Year = $Date[2]; > > > > > -----Original Message----- > > > From: Andre Dubuc [mailto:[EMAIL PROTECTED]] > > > Sent: Wednesday, June 12, 2002 4:11 PM > > > To: [EMAIL PROTECTED] > > > Subject: [PHP] Extracting from an Array > > > > > > > > > I have a db field, type varchar, that is actually a 'date' > > > string formatted > > > as dd-mm-YYYY. I used type 'varchar' (rather than type > > > 'date') since I had to > > > accomplish other things with it. > > > > > > Now, however, I do need to extract the Year (the last four > > > digits in the > > > array). I've tried to access the array $_SESSION['expiry'] > > > but I don't know > > > how to explode this array to extract all characters in last > > > item after the > > > last separator : i.e. '-YYYY'. I've used "-" as the > > > separator, but I just > > > get the first number of the last part of the array, i.e.: '-Y'. > > > > > > Is there a way of extracting all characters in that array? > > > > > > I've tried a bunch of combinations, but I obviously don't > > > understand the > > > basic mechanics of array manipulation or 'slicing'. If > > > someone could point me > > > to a good resource, or explain what I'm doing wrong, I would > > > greatly any > > > assistance. > > > > > > Tia, > > > Andre > > > > > ************************************************************************ ** > * > >* This message is intended for the sole use of the individual and entity > to > > whom it is addressed, and may contain information that is privileged, > > confidential and exempt from disclosure under applicable law. If you > are > > not the intended addressee, nor authorized to receive for the intended > > addressee, you are hereby notified that you may not use, copy, disclose > or > > distribute to anyone the message or any information contained in the > > message. If you have received this message in error, please immediately > > advise the sender by reply email and delete the message. Thank you very > > much. > > -- > Please pray the Holy Rosary to end the holocaust of abortion. > Remember in your prayers the Holy Souls in Purgatory. > > May God bless you abundantly in His love! > For a free Cenacle Scriptural Rosary Booklet: http://www.webhart.net/csrb/ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php