I have a table that stores the date/time as a Unix timestamp.
Is it possible to query the table and pick out all the entries that are a Monday without having to query all the rows and process them outside of MySQL?
Thanks!
SELECT * FROM your_table WHERE DAYOFWEEK(FROM_UNIXTIME(your_unix_timestamp_column)) = 2
Related
Question 1:
Given the mySQL database table named tbl_accts with columns... acct_name, acct_xdate, acct_ydate
How to create a sql query that returns records where acct_xdate is greater than acct_xdate?
the below query returns no records which is incorrect
SELECT acct_name,acct_xdate,acct_ydate FROM tbl_accts WHERE acct_xdate > 'acct_ydate'
Question 2:
Possibly the dates are stored in different formats. How to test a date field to see what format the date is stored in?
Thanks for any help.
mysql - I have a table , a column of unix timestamps called time, which I have already changed to datetime format, but I can't select other columns of my table.
To change the unix timestamps I have used the following statement:
SELECT
from_unixtime (time)
FROM
calllog
and changed to datetime format successfully, but when I add other columns to the select query the result is 1 in all the time columns. What can be done?
I want to retrieve a time from Mysql table and want to get it's difference with current time time.
To be More clear :
[Current_Time]-[Time retrieved from SQL TABLE] = HH:MM:SS
You can do the calculation in the database. For instance, if the "time column" is stored as datetime:
select timediff(now(), t.timecol)
from table
If the timecol is stored as a time data type, then use:
select timediff(curtime(), t.timecol)
from table
I got an existing Mysql table with one of the columns as time int(10)
The field has many records like
1455307434
1455307760
Is it a date time, encrypted.
What should be the select Query, so it should display an actual date.
FROM_UNIXTIME()
SELECT FROM_UNIXTIME(mycolumn)
FROM mytable
I need to get the record from one table where date between June-30-2011 and June-30-2012.
the problem is that the result is just only display the records of year 2012 although the table has records for year 2011.
below is my code
SELECT * FROM tbl_name where date between '06/30/2011' and '06/30/2012'
you need to convert it bact to date using STR_TO_DATE, eg
SELECT *
FROM tbl_name
where STR_TO_DATE(date, '%m/%d/%Y') between '2011-06-31' and '2012-06-31'
STR_TO_DATE
It is not good to store Dates as string on database because as you see it is hard to search for it, you need some extra functions to convert it back to date and to which I think it kills the index.
If you have time or privilege to alter, fix the values and change it to DateTime data type.