Achilles
Achilles

Reputation: 504

SQL/PHP - read part of value

I've text date in value like this "1986-04-24 18:25:14"

i don't need show the time , how can i read date only ? " the first word of value "

code :

<?php
$id = ((int)$_POST["id"]);
$con=mysql_connect('localhost','dbuser','pass');
mysql_query("set names utf8");
mysql_query("set charset utf8");
mysql_set_charset('utf8');  
mysql_select_db('dbname',$con);
$query="SELECT * FROM `haevm_userxtd_profiles` WHERE user_id = '$id' AND `key` = 'BASIC_BIRTHDAY' ORDER BY `haevm_userxtd_profiles`.`user_id` ASC LIMIT 0 , 30";
$select=mysql_query($query);
while($row=mysql_fetch_array($select)){
echo $row['value'];
} 
mysql_close($con);
?>

note : i've tried to use SUBSTRING , but i coldn't select , something like this :

SELECT value, SUBSTRING(value,0,1) FROM `haevm_userxtd_profiles` WHERE user_id = '$id' AND `key` = 'BASIC_BIRTHDAY' ORDER BY `haevm_userxtd_profiles`.`user_id` ASC LIMIT 0 , 30

Thank you

Upvotes: 0

Views: 45

Answers (1)

Halayem Anis
Halayem Anis

Reputation: 7785

try with this

SELECT value, DATE(value) FROM `haevm_userxtd_profiles` WHERE user_id = '$id' AND `key` = 'BASIC_BIRTHDAY' ORDER BY `haevm_userxtd_profiles`.`user_id` ASC LIMIT 0 , 30

Upvotes: 1

Related Questions