I have a datetime()
column date_time
in my database.
I need to convert this to date()
and create a new temporary column date_field
till the session ends.
I've tried this:
$query1 = SELECT date_time, date(date_time) as date_field FROM table_name....
This works and creates a temp column date_field
with all the date values for the date_time
field
Problem : This only works for this query. I also have another query which searches for date_time
field and thus results into a DB error Unknown field 'date_field'
.
$query2 = SELECT date_field FROM table_name
| This table doesn't have date_field as a column
Can this field be created so that I can use this for a time till the session ends ? as we do for temporary tables ?
Note: I can't use ALTER to add new column here due to code limitations.
Any ideas ?
Thanks!