English 中文(简体)
• 我SQL的天数总数
原标题:How to Trigger total number of days in mySQL

“我需要建立一个在一天到现在之间显示天数的领域。

TABLE:  reg_add

+------------+---------+
| Name       | Type    |
+------------+---------+ 
| hm_date    | date    |
+------------+---------+ 
| total_days | date    |
+------------+---------+ 

我的客户将在以下日期打字,例如“日志”:2012年5月1日。

我需要在2012年5月1日(即目前)之间显示总天数。

我希望在服务器方面实现这一目标,这对我来说有些新鲜。

我需要建立一个<<>蓬特>GGER,以便永远有更新的“总天数”

我从此开始,我忙于促成并纠正:

SELECT DATEDIFF(curdate(),hm_date) as total_days FROM reg_add

Any help would be appreciated.

页: 1

最佳回答

在埃里克,我使用ts,而不是熟悉我的SQL,但在茨克勒,“亚洲经贸联>执行的职能需要3个参数。 The sytax is

<代码>TEDIFF(最新部分,日期1,日期2>。

I would try DATEDIFF(d,GETDATE(),hm_date) AS total_days FROM reg_add

问题回答

我看了MySQL Trigger Docs,从看,你只能引发事件类型:插入、更新和删除。 因此,您的Trigger赢得了实际上更新了你所希望的全日(本应是天空)。 [你希望能及时更新你的实地工作(每小时十小时更新一次)]。

http://dev.mysql.com/doc/refman/5.0/en/create-trigger.html

我建议撰写一份在网址上的 cr,每天工作一次(或多次),向您介绍最新情况。

在您的信念中,你只得作一 statement: (这应贯穿整个表格,并更新各行各业的日间总数)

UPDATE reg_add SET total_days = DATEDIFF(curdate(),hm_date)




相关问题
Mysql compaire two dates from datetime?

I was try to measure what is faster and what should be the best way to compare two dates, from datetime record in MySql db. There are several approaches how to grab a date from date time, but I was ...

iPhone Date Picker rolls over to 2010 on December 27th?

So I implemented a UIDatepicker in one of my applications for scheduling and autodialing teleconferences... everything is pretty much ready to go except, while testing I noticed that when the date ...

Convert date Python

I have MMDDYY dates, i.e. today is 111609 How do I convert this to 11/16/2009, in Python?

specifying date format when using $form->inputs() in CakePHP

I am wondering if there is a way to specify the date format in the forms created using CakePHP s $form->inputs(); Please note that this is not the individual $form->input() but instead $form->inputs() ...

NSDateFormat, super simple! Where am I screwing up?

Ok, this is really simple, maybe I m a getting a bit burnt out, but seems like it should work, Query XML feed, put out date string, format, display in a cell. The issue is I m a getting a NULL ...

sqlite writing a date into an email

I am exporting a date value from sqlite and placing it into an email. The date appears like this 279498721.322872 I am using Objective C in an Iphone App. Does anyone know how to make this export ...

热门标签