Comparing Dates And Choosing
if( date_add(cur_date(), interval 30 day)>='$thisDate','$thisDate',date_add(cur_date(),interval 30 day)
So: if the current date plus 30 days is larger then thisDate, use thisDate else use the current date plus 30 days.
View Complete Forum Thread with Replies
Related Forum Messages:
Comparing Dates?
i have an 8 digit date string that i want to compare to a column of type 'date' in a MySQL db. the 8 digit string is in the format 'CCYYMMDD'. the question is: do i need to put it into the 'CCYY-MM-DD' format in order to get correct output from the datediff function, or can i simply leave it how it is?
View Replies !
Comparing Two Dates?
I am trying to compare dates in MySQL, but one of my dates from the curdate()-1 method, returns a string that looks like this 20081210 curdate() method returns '2008-12-11' Both are not dates, so they will not compare. Here is my query: SELECT Order_Number FROM <TableName> WHERE date(Order_Date) BETWEEN curdate() AND curdate() -7;
View Replies !
Comparing Dates
I have a problem with me. I am describing the whole situation. I have a table, the structure of the table is as follows: Table Name: Announcement FieldName Data Type(Size) Announcement Varchar(50) St_Hr Decimal(10,0) St_Min Decimal(10,0) St_Day Decimal(10,0) St_Mon Decimal(10,0) St_Year Decimal(10,0) End_Hr Decimal(10,0) End_Min Decimal(10,0) End_Day Decimal(10,0) End_Mon Decimal(10,0) End_Year Decimal(10,0) The data stored is: Test Announcement,10,20,6,10,2005,11,0,8,10,2005 Now, I have to write a query to retrive announcements after filtering them as per the mentioned Starting and Ending Date & Time. The condition should use the local date and time.
View Replies !
Comparing Dates If One Is Unix Timestamp
I'm building a simple cms and i'm trying to get something done.. I store the dates as UNIX timestamps. However i want to add a feature let's say to display how many entries have been posted today. Something like [Articles posted today: 3]
View Replies !
Comparing Dates Y, M, D , Time In Sql Query
ok.. ive finally got my nice little calender setup to output my dates now how do i query my database for example ive got 2 variables $startdate = 2006-1-1 00:00:01 $enddate = 2006-1-1 23:59:59 these represent the 1st and last second of the first of january 2006 i have a cell in my table (table called challenges) ( cell called time) that contains a date in the same format for each entry how do i get all the entries between the start time and the end time.. can i use less than < and more than > as these are not really integar values the column type is datetime but there is also another column of type datetime
View Replies !
Comparing Dates Stored In The Format Yyyy-mm-dd
Hello, I have a date field in a mysql database, that is stored in the format yyyy-mm-dd. I would like to subtract 10 days from the date and then compare it to the current day, so say I select a date in the db is 2008-09-15, I want to compare today (2008-07-28) to 2008-09-05. How would I do this? (I'm using php).
View Replies !
Comparing String Dates To Current Date For Month And Day
Trying to set the display column to a no if the ending date is before or at the current date. Comparing string dates to the current date for month and day only. Am using CONCAT because the ending date needs to be figured into a date as month_end is in a varchar type and day_end is a tinyint type. The query does run, but it affects everything where continuous != 'always' - seeming to ignore the AND part. UPDATE Listings SET display = 'no' WHERE continuous != 'always' AND STR_TO_DATE(CONCAT(month_end, '-', day_end), '%M-%e') <= DATE_FORMAT(CURDATE(), '%M-%e') What should be done differently here?
View Replies !
Version Choosing
Could you give me some advice? 1. Should I choose mysql 5.0 or 5.1 with some msyql-cluster? 2. Which mysql-cluster is more stable, mysql-cluster 6.2 or 6.3 ? 3. Or am I too early to think about mysql-cluster?
View Replies !
Choosing A Version
would just like to know which version of mysql to install. Apparently I need the i686 version, but I can only find 64bit options. I have a 32bit PC. >uname -a Linux ubuntu 2.6.27-9-generic #1 SMP Thu Nov 20 21:57:00 UTC 2008 i686 GNU/Linux
View Replies !
On Choosing The Right Type For A Column
The online MySql manual gives advice on column types for the most efficient use of storage, but I can't find any advice on column types for the most efficient use of computer cycles. I know on some machines it may be faster always to use (say) fixed length strings and unsigned integers, even if these types take up more storage than is strictly needed. Does any reader of this ng have an informed opinion on this matter?
View Replies !
Choosing A Particular Row From Grouped Rows
I have a table which contains two strings and a date. page_views ----------------- sessionId page timestamp This is added to each time someone views a page on our site. I want to select the last page each user looked at, so I need to group on the sessionId whilst getting it to select the one with the highest date timestamp.
View Replies !
Choosing From Multiple Tables
I have a table of users where some users have a "commander" who will benefit from that users stats. This is updated daily where a users benefits are calculated and updated via a cronjob. I would like to update users, and if they have commanders, update them as well in the same MySQL statement. So the only way I can do it no is like this: Expand|Select|Wrap|Line Numbers
View Replies !
Choosing Index Type
I use mysql 5.0.18. I need some advice in what type of index to prefer when using MEMORY tables - BTREE or HASH? I want to put in memory several tables with number of rows from 100 throuh 20000 in each. Not a lot I guess. My memory tables contain a kind of vocabulary with common table structure like create table: ( id int, name CHAR(200), primary key (id), {key | unique key} `name` (name) ) There can be duplicates in some columns but I feel it would not be many of them. Is it possible to gain meaningful time profit from choosing one index type and not the other when selecting from such tables? (selects may contain many joins with these tables)
View Replies !
Choosing The Right Local Server
i seem to have a problem with connecting to the database on everything i try! At the moment I am trying to connect moodle to my MySQL database. I want the MySQL host to be pcol-webtest - as this is the server host - not locahost at all. How do I change the host, do I have to set the database data directory onto that host? Through MySQL Administrator its telling me the following: Connected to MySQL Server Instance Username: mooldeadmin (set this in command line) Hostname: localhost Port: 3306 Server Info MySQL version: MySQL 4.1.10-nt via TCP/IP Network Name: pcol-webtest IP: 212.219.110.235 OS: Windows 2k
View Replies !
Using IF() For Choosing The Query Fails
The following code is for the Archive. (Where users can store special messages) I want to receive one row for each message that has been sent OR that has been received. With the code beneath I get this error: "#1241 - Operand should contain 1 column(s)". How can I fix this? INFO AND CODE ......
View Replies !
Choosing A Linux Distribution
I'm building up a mysql server to run our lab's internal data base, and was wondering how to go about choosing a linux distribution. Anyone have any advice as what to take into consideration, or have any specific advice? Also, is there any big disadvantage to just running the server on an XP box? The server itself will run on an AMD 64 processor.
View Replies !
Choosing Storage Engine
I am setting up a database and I was wondering what storage engine to use, MyIsam or InnoDB. First of all I am looking for the most trustworthy solution. I have been searching the forum, but I could not find a definitive answer. I did find that MyIsam is faster than InnoDB, but InnoDB provides better data integrity and would even be more robust. I do not need full-text searching. I foresee to access the database using PHP/Apache. InnoDB would be the best way to go then, right? Second question, if it was not for full-text searching, why would anyone choose for MyIsam, is it really that faster?
View Replies !
Converting MS Access Dates To MySQL Dates During LOAD DATA INPUT ?
My insert code is below. The MySQL server is on my local machine and is version 4.1.22. I am exporting from an access table with 6 fields to a mysql table with those 6 plus 5 more fields. The main problem I am having SO FAR, is converting dates. The data file dates are formated like: 2/2/2006 0:00:00, 12/20/2006 9:22:05 Any ideas how to format those into mysql friendly dates? Also, how do I convert currency fields in the load data process? I know you use SET by what kind of formula? =========================================== LOAD DATA INFILE 'C:Documents and Settingspath_to_filedata.txt' INTO TABLE auto (field2, field3, field4, field5, currency_field6, field7, date_field8, date_field9) SET id = MD5(UUID()) FIELDS TERMINATED BY ',' LINES TERMINATED BY ' '
View Replies !
Choosing A Version Of MySQL For Local Web Server
In the process of setting up a localhost web server to test things before I put them on my shared host server. Mostly I'm just dabbling - not making a living at it. My server is Apache 2.2.3 with PHP 5.2.0 on WinXP-Pro. What version of MySQL is most compatible with these versions of server software? Can someone point me to an installation how-to doc? Would also appreciate pointers to pages I should read to familiarize myself with MySQL. I've dabbled with dbs's as standalone apps but never used one on a server before.
View Replies !
Update String Dates Into Mysql Dates
I've got a table that someone created with varchar fields for month, day, and year. I've added a DATE field to the table, and now I want to combine all three of these strings into one DATE and stick it into the DATE field. Once I've got this done, I can delete those three varchar fields and just have the nice DATE field. Here's the command I've tried in several variations but no luck--syntax errors every time: UPDATE SET OCR_Entry_Date = date_format(str_to_date(concat_ws('-', OCR_MM, OCR_DD , OCR_YYYY) ,"%b-%d-%Y"), "%m-%d-%Y") WHERE OCR_YYYY = '1974' OCR_Entry_Date is a DATE field and the others are the varchar fields. My logic is basically: 1. concatenate the separate field values into a single string 2. convert the string into a date 3. format the date in the way I'd like it in the table
View Replies !
MSSQL Dates -> MySQL Dates Automatically?
We're using data feeds that were originally meant for MS SQL and the dates in the data feed (tab delimited text files) are formated like: Oct 21 2007 In MySQL, the date fields are formatted as datetime fields and when we do an import the dates all come through as 0000-00-00 00:00:00. We're importing using the MySQL "LOAD DATA LOCAL INFILE" command and just dumping the text files right into freshly truncated tables. Is there a way when loading the files to find and replace the dates maybe? Can MySQL convert the dates? I have a shell script downloading an archive and uncompressing, then it runs a PHP script that loops through the files runningt he LOAD DATA command. Any advice would be appreciated... I'm just looking for the easiest (and least server-intensive) way to get the date issue fixed. We've already tried begging the vendor but they're not yet ready to start supporting other date formats (even though their MS SQL db can output a date format friendly to MySQL). Thanks!
View Replies !
List All Dates Between 2 Diff Dates
I have a database which stored financial data daily exclude weekend, however sometimes i tend to forget to upload data into the database. How do i write a sql query that would detect the missing dates between from last updated date until the current date.
View Replies !
Dates Pre 1970 And Dates After 2050
i have MySQL version: 4.1.16-nt, when i try to insert a date pre 1970 or after 2050 into a timestamp field, the date is stored as all 0's, how can i save a date pre 1970 and after 2050 into a mysql field?
View Replies !
List All The Dates Between 2 Given Dates Using SELECT
how I can list all the dates between 2 dates (inclusive) using SELECT sql statement in mysql? I have a member table with the following columns: id int autoincrement name varchar(40) join_date date I want the following output (date, count of members joined on that date): 1 April 2009...... (2 members joined) 2 April 2009...... (0 members joined) 3 April 2009...... (3 members joined) .....so on ...upto 30 April 2009.....(1 members joined) For the above output I need the SQL command that is valid in mysql. Is there anyone who can produce the above result with a single SELECT command. Please don't suggest that is possible using php for loop or creating a mysqlorary table first and then inserting all the dates into it. Then make a join between mysql table and members table using date as GROUP by column etc. etc. I know this is possible using some user variables as I searched through the various SQL tutorial sites. But I am unable to figure out how I can produce a list of all dates between 2 given dates.
View Replies !
Stroring Dates Perior To 1 AD, BC Dates
I need to store some dates that can be BC, However I received a problem indicating Incorrect Datetime. I have read the documentation, and it says that Date&DateTime types can store from 1000-9999 AD, and Timestamp stores less year ranges. What other options do I have to store dates before 1000 AD !
View Replies !
How To List All Missing Dates Between 2 Dates
I have a database which stored financial data daily exclude weekend, however sometimes i tend to forget to upload data into the database. How do i write a sql query that would detect the missing dates between from last updated date until the current date.
View Replies !
Dates, Dates, Dates - Syntax Help Please!
OK, I have a MySQL table which contains, among others, a field called date which stores dates in the format YYYY-MM-DD HH:MM:SS. What I'd like to do is select a list of all the months present (without repetition), preferably in the format YYYY-mm
View Replies !
Comparing Age
So the birthdays in my MySQL table are in a column called DOB and in the format of say: March 8 1985. Now i have my own PHP function that will convert that to a nice numerical value of age relative to today, which is perfect. it is called getAge(). However, i can't seem to be able to parse an SQL query with that function inside...is there any way to parse my own PHP functions inside an SQL query?
View Replies !
Comparing
I'm currently working with two tables; A scheduling table and a document table. Basically I'm trying to make a query that says this -- "give me everything from this month and day in the Document table that's not in the Schedule"
View Replies !
Comparing Versions Of Sql
I'm taking up a new position and have never used sql before although use and code in lots of other languages. When doing a bit of survey I find many many versions of commercial and public versions of sql. Can anyone tell me if the syntax is generally similar or are they completely different. If I invest time learning mysql on XP or Linux will that be useful if I end up using something like Oracle later on? The only one I would avoid is MS.like things that work occasionally.
View Replies !
Comparing Two Tables
I have these tables: table02 Id | tab01_field 1 | 00258 2 | 00041 Code: table01 Id | tab01_field 1 | 00258 2 | 00123 3 | 00825 4 | 00041 5 | 00005 table02 Id | tab01_field 1 | 00258 2 | 00041 When run a query to see the common records in both tables it returns a right result select table01.tab01_campo from table01,table02 where table01.tab01_field=table02.tab01_field Code: 00258 00041 But when I try to see the the uncommon records it returns select tab01_campo from table01,table02 where table01.tab01_field<>table02.tab01_field Code: 00258 00123 00123 00825 00825 00041 00005 00005 You can see, it returns the uncommon records twice, but also returs the common records. How could make a query tah returns only the uncommon records? Code: 00123 00825 00005
View Replies !
Comparing Times
I'm creating a voting system, and want to prevent people from cheating. Therefore I'm logging their IP, and the time they voted, and what I'm planning to do is have a script which will delete any records which have been in the database for say 24 hours. To get the length of time I was gonne use: HOUR(TIMEDIFF(NOW(),time))
View Replies !
Data Comparing
i'm writting a program that uses my sql to compare a date time feild to a date that i have to count call on one date the statment looks like this: SELECT Count(*) FROM wab_answers WHERE wabScreen=1 And DateDiff(answerTime,'" & curDate & "')=0; where curDate is string containing the date that i would like to compare. I'm not to sure on the correct way to do this. Just need a push in the right direction.
View Replies !
Comparing Differences
I want to find the fields that are in table A but not in table B. If I have: table A: id, name, scoreA table B: id, name, scoreB I want to find the scores that are in table A but not in B, by example: table a: 1,john,12|2,mike,14|3,neal,17 table b: 1,hellen,14|2,nolhan,12|3,vicky,10 After make the query: Score in A that are not in B: 17
View Replies !
Comparing Columns Using LIKE
I can write "column1 LIKE column2" to compare two columns in a fuzzy way, but what about "%" to indicate what should be compared? column2 contains a list (separated by spaces) of the single values that can be found in column1, so I need to use %value%. I've already validated the values, and they are always a single word, so there's no risk using LIKE per se. Any more elegant way to do this without having to resort to a PHP loop?
View Replies !
Comparing Strings
I can't work out but i'll try to present it simply here. Assume the table "Names". FirstName, SecondName Robert Smith John Jones Richard Robertson Mike Richardson Ian Stevenson I need to write a query where by it selects all records where the First Name appears as part of any second name. the output should be Robert Smith Richard Robertson Now, I know I can do SELECT FirstName, LastName FROM Names WHERE LastName LIKE '%Richard%'; This will find all records where Richard appears as part of a last name. But I want it to work for any first name not just a specific one. i basicly need the last line to be something int he order of WHERE LastName LIKE '%FirstName%'; only a version that works.
View Replies !
Comparing Within A Column
i have a table 'packets' with the following structure : ip_src varchar(20),mac_source varchar(20) .now i want to list all those ip_src which would have more than one mac_source. how do i go about doing this?
View Replies !
Comparing String To Int
I would like to know what is the performance behavior in reading an writing string and int in several database tables. What i should use in terms of performance, int or string?
View Replies !
Comparing Two Fields With LIKE
Here's the sql: SELECT * FROM boxer.lpars a, boxer.libraries b WHERE b.lpars LIKE '%a.lpar%' AND a.deleted = 0 ORDER BY node, lpar b.lpars will commonly look like: "WIN1#WIN2#WIN3#WIN4#" a.lpar will commonly look like: "WIN1" When I run this query I get zero matches. What do I need to do to match fields using LIKE?
View Replies !
Comparing Two Table
I have two tables: CREATE TABLE `FootballerScore` ( `footballerID` mediumint(4) NOT NULL default '0', `GameWeekID` mediumint(4) NOT NULL default '0', `GameRuleID` mediumint(4) NOT NULL default '0', `Goals` mediumint(4) NOT NULL default '0', `Assists` mediumint(4) NOT NULL default '0', `CleanSheets` mediumint(4) NOT NULL default '0', `YellCards` mediumint(4) NOT NULL default '0', `RedCards` mediumint(4) NOT NULL default '0', `WeeklyScore` mediumint(4) NOT NULL default '0', `AccScore` mediumint(6) NOT NULL default '0', PRIMARY KEY (`footballerID`,`GameWeekID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; CREATE TABLE `footballers` ( `footballerID` mediumint(15) NOT NULL default '0', `fname` varchar(15) collate latin1_general_ci NOT NULL default '', `sname` varchar(15) collate latin1_general_ci NOT NULL default '', `value` decimal(15,1) NOT NULL default '0.0', `PremTeamID` mediumint(15) NOT NULL default '0', `position` varchar(15) collate latin1_general_ci NOT NULL default '', `Importance` varchar(4) collate latin1_general_ci NOT NULL default '', PRIMARY KEY (`footballerID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; The footballers table basically has a list of all the players in the premiership and the footballerscore table has a list of the player who played in a given week. For any one week I need to find out who DIDNT play. I can do this by comparing all the footballerIDs in both tables and the difference is the group I need. However I'm not sure how to put this into an SQL statement.
View Replies !
Comparing A Csv To A Db Table
How would I go about comparing values in a CSV file to a table in the database, and then removing any rows where that value (an email address) matches? Is this something I can do in phpMySQL or will I need to create a separate PHP script or something? I maintain a mailing list using something called ListMessenger. It's a great web application, but the one major drawback is that it doesn't have a way to handle bounces. Over the course of 5-6 years, I'm now up to around 800-900 bounced emails every time I send out a newsletter. I'd really like to clean up the list and I was able to extract all the bounced address from my email client. I'm just not sure how to do it. I actually have an idea of what needs to be done... it's more the actual code to make it happen that I'm not sure of. I'm thinking it would be something like this: 1. Open csv file and read values into an array 2. Run a SQL statement that removes any rows from the "users" table if the "email_address" field matches any of the addresses in the array. Any help would be greatly appreciated. I can get into more specifics as far as the table/column names and stuff,
View Replies !
Comparing Tables
I have a query that produces a list of names of people who have completed a certain course. I want to be able to run a report which can show who has not completed this course. The code I have attached below just returns the same result as those who have sat the course....
View Replies !
Comparing Timestamps
My table keeps track of the last time a program was run and how often that program is supposed to be run. I want to retrieve all the rows where the program is scheduled to run again: ... WHERE NOW() > (last_runtime + run_frequency) last_runtime and run_frequency are both TIMESTAMP field types Is there a way do this, or do I need to convert these fields into something other?
View Replies !
|