English 中文(简体)
PHP 需要帮助 MYSQL DB和日期
原标题:PHP Need help with MYSQL DB and dates

我在非洲开发银行有两个领域,说明开办和结束时间,另一个领域可能或可能没有确定日期。

在选举后,我需要知道,我是否在时间范围内,如果我是在时间范围内,到今天才确定日期。

在购买力平价中这样做的最佳方式是什么?

感谢!

最佳回答

我的原始回答并不是在我所了解的一切情况下回答你的问题。 希望这样做。

$query = "SELECT IF(".date( H-m-s )." BETWEEN start-time AND end-time, 
 inRange ,  notInRange ) WHERE `date` == CURRENT_DATE OR `date` IS NULL";

If date( H-m-s ) from PHP is in the range it will return the string "inRange" otherwise it will return the string "notInRange" and will match it on the records in your db where date is either NULL, or the current date.

你们也可以这样作:

SELECT IF(TIME(CURRENT_TIMESTAMP) BETWEEN start-time AND end-time,  inRange ,
 notInRange ) WHERE myDate == CURRENT_DATE OR myDate IS NULL;
问题回答

在选任后,我需要知道我是否在时间范围内或超过时间范围。

SELECT (NOW() BETWEEN date_min AND date_max) is_happening_now
  FROM your_table

如果NOW(NOW)在从日期到最高日期之间,则现在含有一种含有真实情况的细菌。 显然,这将建立一个你可能不需要的单独一栏,如果有必要,你可以将这一条件列入《惠予公约》条款。

如果确定日期,我只是在今天的时候。

我确实不理解这一部分,但你可以从DATETMIS中抽出这一日期,并履行DATE职能(例如: Current_date = DATE(一些_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 ...

热门标签