欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

MySQL内置时间curdate查询用法

程序员文章站 2022-06-02 09:06:28
...

mysql SELECT year(curdate()); +-----------------+ | year(curdate()) | +-----------------+ | 2009 | +-----------------+ 1 row in set (0.00 sec) mysql SELECT month(curdate()); +------------------+ | month(curdate()) | +------------------+

  mysql> SELECT year(curdate());

  +-----------------+

  | year(curdate()) |

  +-----------------+

  | 2009 |

  +-----------------+

  1 row in set (0.00 sec)

  mysql> SELECT month(curdate());

  +------------------+

  | month(curdate()) |

  +------------------+

  | 8 |

  +------------------+

  1 row in set (0.00 sec)

  mysql> SELECT day(curdate());

  +----------------+

  | day(curdate()) |

  +----------------+

  | 9 |

  +----------------+

  1 row in set (0.00 sec)

  mysql> SELECT curdate();

  +------------+

  | curdate() |

  +------------+

  | 2009-08-09 |

  +------------+

  1 row in set (0.00 sec)

  mysql> SELECT dayofmonth(curdate());

  +-----------------------+

  | dayofmonth(curdate()) |

  +-----------------------+

  | 9 |

  +-----------------------+

  1 row in set (0.00 sec)