Jump to content
Sign in to follow this  
fil79

dúvida mysql

Recommended Posts

fil79

Boas

tenho a coluna data de uma tabela Mysql com o formato dia/mes/ano (10/10/2008)..

Queria fazer um select somente ao mes e para tal estou a tentar usar a função RIGHT

SELECT right(data,7) FROM tabela

Acontece que assim devolve os ultimos sete caracteres (10/2008) , o que queria era restringir apenas aos dois primeiros (mês), como a função de PHP substr permite fazer. Desde já agradeço


MCITP-MCTS-MCP

Share this post


Link to post
Share on other sites
elcsat

tu tens funçoes em mysql para isso

por exemplo comparar duas datas a data actual com uma que ta na base de dados, mas tens que ter cuidado tambem ao escrever na base de dads respeitar a ordem

select * from anunciar where DATE_FORMAT(DATE_SUB(NOW(), INTERVAL '07' DAY), '%x-%m-%d %H:%i:%S') < DATE_FORMAT(data_inic, '%x-%m-%d %H:%i:%S')

ver este site que tens aqui tudo:)

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html

espero que seja isto

:P :)

Share this post


Link to post
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.

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.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. 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.