0

Hi,
my table has
id,startdate,enddate,starttime,endtime,salelocation,imagename
both dates are in date type and starttime and endtime are in time type.
I want to check if my data consisting of startdate,starttime,enddate,endtime cannot be present in table and must be a valid date and time duration.
How to check this valid date and time interval?

my problem was not validating date or time.

Duration of startdate with starttime and enddate with endtime can't be present in table,
It must be a valid interval for sale a particular product.
Thanks
Ramakrishnan t

Edited by ramakrishnankt: adding additional info

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by ramakrishnankt
0

When storing data in a MySQL table with PHP you are best off converting it to Unix Time
(See http://php.net/time)
From there you can convert it into any function as well as running functions like

$StartTime = time();
$EndTime = time()+60*60*60;
echo date('H:i:s', $StartTime-$EndTime);//Returns 1:00:00

Edited by samarudge: Mistake in cocd

0

When storing data in a MySQL table with PHP you are best off converting it to Unix Time
(See http://php.net/time)
From there you can convert it into any function as well as running functions like

$StartTime = time();
$EndTime = time()+60*60*60;
echo date('H:i:s', $StartTime-$EndTime);//Returns 1:00:00

Hi,

my problem was
Duration of startdate with starttime and enddate with endtime can't be repeat or override or not inbetween in table,
It must be a valid interval for sale a particular product.
I need mysql query to do this.
Thanks
Ramakrishnan t

Edited by ramakrishnankt: adding info

0

I got solution

$query="SELECT * FROM rosesgif_rgi.rgi_specialsalesschedule where ((salelocation='".$Salelocation."') and (('".$startdatetime."' between startdatetime and enddatetime ) or ('".$enddatetime."' between startdatetime and enddatetime ) or ('".$startdatetime."' < startdatetime and '".$enddatetime."' > startdatetime )))";


if it returns record means already record available.
startdatetime,enddatetime are datetime type.

Edited by ramakrishnankt: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.