Re: Need a short directive

2014-10-08 Thread Trianon 33

A big thanks to Johan, who pointed me in the right direction.

I had indeed to fix a where clause, but in the end al went very well.

BR, hans.



Johan De Meersman schreef op 07-10-14 om 16:10:

- Original Message -

From: Trianon 33 triano...@gmail.com
Subject: Need a short directive

Values from yearanddate look like this: 2013-12-11 00:00:00. I want to

That's only a display format; internally it's an integer (well, presumably a 
struct time_t) counting the seconds since epoch. Not especially relevant except 
to say that, since it's only an output format, it can easily be changed.


copy the 2013 and put that into the yearfield, for each record.

Can that be done by just using SQL statements?

I believe the year() function is pretty much what you're looking for; complexer 
things can be handled through date_format().

Something along the lines of

  UPDATE table
SET year = year(yearanddate);

should do nicely; I'm sure you can fix up a where clause as appropriate.





--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql



Re: Need a short directive

2014-10-07 Thread Johan De Meersman
- Original Message -
 From: Trianon 33 triano...@gmail.com
 Subject: Need a short directive
 
 Values from yearanddate look like this: 2013-12-11 00:00:00. I want to

That's only a display format; internally it's an integer (well, presumably a 
struct time_t) counting the seconds since epoch. Not especially relevant except 
to say that, since it's only an output format, it can easily be changed.

 copy the 2013 and put that into the yearfield, for each record.
 
 Can that be done by just using SQL statements?

I believe the year() function is pretty much what you're looking for; complexer 
things can be handled through date_format().

Something along the lines of 

 UPDATE table
   SET year = year(yearanddate);

should do nicely; I'm sure you can fix up a where clause as appropriate.


-- 
Unhappiness is discouraged and will be corrected with kitten pictures.

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql



Re: Need a short directive

2014-10-07 Thread Trianon 33

Thanks, later on I'm going to try this, will post results here.

Bye, Hans.


Johan De Meersman schreef op 07-10-14 om 16:10:

- Original Message -

From: Trianon 33 triano...@gmail.com
Subject: Need a short directive

Values from yearanddate look like this: 2013-12-11 00:00:00. I want to

That's only a display format; internally it's an integer (well, presumably a 
struct time_t) counting the seconds since epoch. Not especially relevant except 
to say that, since it's only an output format, it can easily be changed.


copy the 2013 and put that into the yearfield, for each record.

Can that be done by just using SQL statements?

I believe the year() function is pretty much what you're looking for; complexer 
things can be handled through date_format().

Something along the lines of

  UPDATE table
SET year = year(yearanddate);

should do nicely; I'm sure you can fix up a where clause as appropriate.





--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql