sql

日付けの減算

mysql> select now(), date_sub(now(), INTERVAL 1 DAY), date_sub(now(), INTERVAL 1 MONTH); +---------------------+---------------------------------+-----------------------------------+ | now() | date_sub(now(), INTERVAL 1 DAY) | date_sub(now…

postgresqlで今月やつだけとる

postgresはMONTHない 今月のエントリされた日付けをとりだす。 select date_part('day',entry_datetime) as day from entry where date_part('month',entry_datetime) = date_part('month',now()); 2007年2月のエントリだけ取り出す。 select * from entry w…