MySQL CURDATE() Function
The CURDATE() function returns the current date.
Note: The date is returned as "YYYY-MM-DD" (string) or as YYYYMMDD (numeric).
Note: This function equals the CURRENT_DATE() function.
SELECT CURDATE() + 1;
create table vlr (name varchar(20),bdate date,btime time,bdt datetime);
---------------
MySQL CURTIME() Function
The CURTIME() function returns the current time.
Note: The time is returned as "HH-MM-SS" (string) or as HHMMSS.uuuuuu (numeric).
Note: This function equals the CURRENT_TIME() function.
--------------
MySQL NOW() Function
The NOW() function returns the current date and time.
Note: The date and time is returned as "YYYY-MM-DD HH-MM-SS" (string) or as YYYYMMDDHHMMSS.uuuuuu (numeric).
Mounika@MOUNIKA-PC c:\xampp
# ram.cmd
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 10.4.18-MariaDB mariadb.org binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> use vlrinst
Database changed
MariaDB [vlrinst]> show tables
-> ;
+-------------------+
| Tables_in_vlrinst |
+-------------------+
| emp |
| emp1 |
| people |
| vlr |
+-------------------+
4 rows in set (0.255 sec)
MariaDB [vlrinst]> drop table vlr;
Query OK, 0 rows affected (0.309 sec)
MariaDB [vlrinst]> select curdate();
+------------+
| curdate() |
+------------+
| 2021-05-22 |
+------------+
1 row in set (0.036 sec)
MariaDB [vlrinst]> select now();
+---------------------+
| now() |
+---------------------+
| 2021-05-22 22:12:43 |
+---------------------+
1 row in set (0.001 sec)
MariaDB [vlrinst]> select curtime();
+-----------+
| curtime() |
+-----------+
| 22:13:07 |
+-----------+
1 row in set (0.001 sec)
MariaDB [vlrinst]> create table vlr (name varchar(20),bdate date,btime time,bdt datetime);
Query OK, 0 rows affected (0.423 sec)
MariaDB [vlrinst]> desc vlr;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| name | varchar(20) | YES | | NULL | |
| bdate | date | YES | | NULL | |
| btime | time | YES | | NULL | |
| bdt | datetime | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
4 rows in set (0.046 sec)
MariaDB [vlrinst]> insert into vlr values("ram",curdate());
ERROR 1136 (21S01): Column count doesn't match value count at row 1
MariaDB [vlrinst]> insert into vlr() values("ram",curdate());
ERROR 1136 (21S01): Column count doesn't match value count at row 1
MariaDB [vlrinst]> insert into vlr() values("ram",curdate(),curtime(),now());
Query OK, 1 row affected (0.070 sec)
MariaDB [vlrinst]> slect * from vlr;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'slect * from vlr' at line 1
MariaDB [vlrinst]> select * from vlr;
+------+------------+----------+---------------------+
| name | bdate | btime | bdt |
+------+------------+----------+---------------------+
| ram | 2021-05-22 | 22:16:03 | 2021-05-22 22:16:03 |
+------+------------+----------+---------------------+
1 row in set (0.025 sec)
MariaDB [vlrinst]> insert into vlr() values("kumar",curdate(),
-> curtime(),now());
Query OK, 1 row affected (0.045 sec)
MariaDB [vlrinst]> slect * from vlr;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'slect * from vlr' at line 1
MariaDB [vlrinst]> select * from vlr;
+-------+------------+----------+---------------------+
| name | bdate | btime | bdt |
+-------+------------+----------+---------------------+
| ram | 2021-05-22 | 22:16:03 | 2021-05-22 22:16:03 |
| kumar | 2021-05-22 | 22:18:18 | 2021-05-22 22:18:18 |
+-------+------------+----------+---------------------+
2 rows in set (0.001 sec)
MariaDB [vlrinst]>
No comments:
Post a Comment
Note: only a member of this blog may post a comment.