Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Select problem 1

Status
Not open for further replies.

randy4126

Programmer
Joined
Jun 2, 2001
Messages
62
Location
US
I am trying to insert data into a table from another table. The problem comes in with the unix timestamp column. It always converts the the date to 0000-00-00 but if you run the select query by itself it works just fine(Gives the correct date). Could someone see what I am doing wrong. Here is my SQL statement:


Code:
Insert Into HistoryPeaksSGBW (SGID_HPSGBW, Bandwidth_HPSGBW, SDStreams_HPSGBW, HDStreams_HPSGBW, EffectiveStreams_HPSBW, TimeStamp_HPSGBW)
Select SGID_CSGBW, Bandwidth_CSGBW, SDStreams_CSGBW, HDStreams_CSGBW, EffectiveStreams_CSGBW, FROM_UNIXTIME(TimeStamp_CSGBW,'%Y-%d-%m')
from CurrentSGBW

Thanks for you help.

Randy
smiletiniest.gif
 
that's because (some of) your dates are invalid

mysql insists on year-month-day sequence when specifying a date (although the date is stored internally completely differently)

use '%Y-%m-%d' instead of '%Y-%d-%m'

:-)

rudy | r937.com | Ask the Expert | Premium SQL Articles
SQL for Database-Driven Web Sites (next course starts May 8 2005)
 
That was it. I didn't notice I had the order wrong. I remember reading that in the docs now. Thanks a LOT!

Randy
smiletiniest.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top