Jump to content

Recommended Posts

hi frnds,

 

i have a problem that i cant able to write a query for comparing the two dates.

i have fields like reqfrom and reqto as DateTime format for conference room booking.Now the problem is new datetime should not conflict with previous datetime.

For example:

some one booked the room from 29-09-07 10:30 AM to  29-09-07 11:30 AM.now if i  booking the room from 29-09-07 9:30 AM to 29-09-07 12:30 PM then the system should not allow to store.

for this i have written the query like

select count(*) as cnt from conferencebooking where ('2007-09-29 12:01' between ReqFrom and ReqTo) or ('2007-09-29 15:59' between ReqFrom and ReqTo)

but it does not seems to work

 

any one can help me....... ?

Link to comment
https://forums.phpfreaks.com/topic/71137-date-comparison/
Share on other sites

[pre]

  Booking              ReqFrom        ReqTo

                          |              |

    A              [-------]          |

                          |              |

    B                    |          [----------]

                          |              |

    C                    |  [-------]  |

                          |              |

    D                [-------------------------]

                          |              |

    E        [---]      |              |

                          |              |

    F                    |              |          [---------]

[/pre]

 

Conflict occurs (A,B,C,D above) when

BookingEnd > ReqFrom AND BookingStart < ReqTo

where BookingStart and BookingEnd are existing times stored in DB

Link to comment
https://forums.phpfreaks.com/topic/71137-date-comparison/#findComment-357786
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.