Jump to content

Mysql vs Timezone [solved]


Recommended Posts

I've got a query .. .see below

it does some date stuff ...

 

it gets the date from the server (timezone support)

the server this runs on is in a different timezone to me ...

 

who's the SQL wizard here?

SELECT DISTINCT(ID_EVENT),
ID_TOPIC,title,startDate,endDate,members.ID_MEMBER, memberName
FROM calendar
JOIN members USING(ID_MEMBER)
WHERE
(`startDate` >= CURDATE()
AND
`endDate` <= ADDDATE('2008-04-26', interval 7 day))
OR
(`startDate` < CURDATE()
AND
`endDate` >= ADDDATE('2008-04-26', interval 7 day))
ORDER BY startDate
ASC

Link to comment
Share on other sites

you lot a are too slow :)

 

SELECT DISTINCT(ID_EVENT),
ID_TOPIC,title,startDate,endDate,members.ID_MEMBER, memberName
FROM calendar
JOIN members USING(ID_MEMBER)
WHERE
(`startDate` >= CONVERT_TZ(CURDATE(),'UTC','NZ')
AND
`endDate` <= CONVERT_TZ(ADDDATE('2008-04-26', interval 7 day),'UTC','NZ'))
OR
(`startDate` < CONVERT_TZ(CURDATE(),'UTC','NZ')
AND
`endDate` >= CONVERT_TZ(ADDDATE('2008-04-26', interval 7 day),'UTC','NZ'))
ORDER BY startDate
ASC

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...