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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
 Share

×
×
  • Create New...