I have a column called table_date
which currently I am using now()
to insert the current date (2011-02-23
). I know I can manipulate this with sql/php to show me year and monthname. However, I want to know if it's possible to just insert into table_date
the current date as year-month like this 2011-02
? Thanks
A DATE
field is always going to be a full date, and as far as I know, it is also always required to specify a full date.
It might be easiest to use 01
, like 2011-02-01
for February 2011.
Obviously, you can format the output of a DATE
field to your liking when querying it:
SELECT DATE_FORMAT(fieldname,"%Y-%m");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With