/    Sign up×
Community /Pin to ProfileBookmark

Selecting MySQL records using timestamp

Hi, I’d like to ask you a question about MySQL databases and PHP functions to select the records. I’ll explain my situation: I’ve got a database with different fields without an ID, but there’s a field that registers timestamps. I’d like to select only some records from that db based on which day/month/year that record has been created (so using timestamp). In example, there are 2 records in my database which timestamp is set as the same day of the same month of the same year , but it has different hours of input of the record. My goal is to ignore the hour and select, i.e. only records that have a timestamp set as 20th May 2014.
Thanks for the help and sorry for my poor english.

P.S. I’d pref not to have to change field type of the timpestamp fields or manually change their content since the database is already being used.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@DasgarauthorNov 20.2014 — I tried to search on the net and I found this code:

SELECT * FROM

users_test

WHERE

dateadded BETWEEN '2012-02-01 00:00:00' AND '2012-11-01 00:00:00'

Should it work for my case?
Copy linkTweet thisAlerts:
@NogDogNov 20.2014 — Should work as long as the dateadded column is defined as a timestamp or datetime data type.
×

Success!

Help @Dasgar spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...