2013-12-22 66 views
2

我有一個表格設置,如下所示。想要獲取相應日期的日期名稱

表名:活動。

| ACTIVITY_ID |  DATE | ASSIGN_ENGR | TASK_TYPE | TASK_STATUS | 
|-------------|------------|-------------|-----------|-------------| 
|   1 | 2013-12-31 |  Sachin | Monthly | Scheduled | 
|   2 | 2013-12-23 |  Mikel | Weekly |  Done | 
|   3 | 2013-10-18 |  John | Monthly |  Done | 

我想使用查詢獲取日期名稱與我的日期字段。

回答

1

MySQL查詢

SELECT DAYNAME('2007-02-03'); 

輸出:

週六

查詢會是這樣

select Activity_ID, Date , DayName(Date) As Day, Assign_Engr, Task_Type,Task_Status From Your_Table_Name; 

Dayname() function

0
DATE_FORMAT(NOW(),'%a')   # %a: Abbreviated weekday name 

欲瞭解更多信息:w3schools

一個簡單的查詢看起來是這樣的:

SELECT DATE_FORMAT(date, ‘%a’) AS dateday FROM users WHERE id = 1;