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.
Related
I currently have a column ('kWhdate') in a view ('appdatatest') that takes a timestamp column and converts it to a date.
date_format(`t`.`value_timestamp`,'%d/%m/%y%y') AS `kWhDate`
The above is part of the Create View query. It is currently stored as VARCHAR(10). I would like to convert it to a Date. I have tried the following:
ALTER VIEW appdatatest MODIFY appdatatest.kWhDate datetime
SELECT STR_TO_DATE(appdatatest.kWhDate, Date) FROM appdatatest
I have looked at this question Is it possible to change the datatype of a column in a view? but it gives an answer for SQL Server not MYSQL
If possible I could convert in the original CREATE VIEW query
Thanks
You can convert a timestamp to a date with date().
SELECT date(kwhdate) kwhdate
FROM appdatatest;
I have a table in MySQL
Below is the structure of the table.. in that I have 2 column Date and Time and the timestamp is based on the country column.. I would like to convert this time into IST.. can any one help me how can we do this without a mapping table..
mysql query to find data entry not present in table for particular date
I wish to find particular fridays date whose entru is not present in the table
You can query the things that exist in the data. So to find missing dates, you can create a table with all dates in your desired date range and make a query which selects those dates that do not exists in your other table.
I am trying to create a table in mysql. I want to store future dates in that table. I am trying following query:
SQL:
create table dates(submission _date date check(submission _date>curdate));
But this check Clause is not working properly. It accept all dates. Please give me solution.
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