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

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

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.