How To Using Datediff Not Include Saturday And Sunday
Let say, i've this following table
tblapplication
ID | Name | ReceivedDate | ProcessDate
---------------------------------------------------
A009 | Mikaela | 2007-07-06 | 2007-07-11
Then, me do the SQL bewlo to know 'How many days it take to process the application'
select ID,Name,
datediff(ProcessDate,ReceivedDate) as 'NoOfDaysTaken_ToProcess'
from tblapplication
Then the results, shown follows:-
ID | Name | NoOfDaysTaken_ToProcess
---------------------------------------
A009 | Mikaela | 6
My problem is...
How to filter NoOfDaysTaken_ToProcess not include Saturday and Sunday? As a result, the results will get this
Results
ID | Name | NoOfDaysTaken_ToProcess
---------------------------------------
A009 | Mikaela | 4
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Find Out The Date Of The Latest Sunday
Today is 26 December 2006, I want to find out what is the date of the latest sunday that passed by...the date of latest sunday given any day.. what function is used? how to find out?
How To Get The Last Saturday Of Month?
I need to query on the date in one of my table but I need to calculate the last saturday of month first. How do I do that in SQL statement? Specifically, How do I find the last saturday of month given the date (as SQL parameter) in SQL statement in MySQL?
Returning Every Saturday Between Two Dates?
Having a major mental block with this, and was wondering if anyone can help me? Basically I want to create query which will return every occurence of a Saturday between two dates. Looking at the the DAYOFWEEK function, it doesn't appear that you can only provide it with a specific date. The only other way round that I could think of is by having a prepopulated table with all dates within a year and the actual date occurence. I was hoping to do this on the fly, as the query would be used as part of trigger.
DateDiff
I have to write an app that interacts with mySQL (I really must have done some evil, evil stuff in a previous life to be landed with this!) I need to work out the difference in days between values in the database and the current date. "No problem," thought I , "I'll just use the SQL DATEDIFF command." Heh! Well, the user interface I'm using didn't even recognise DATEDIFF as being a function, so I decided to visit the mySQL website. Their description of DATEDIFF is as follows: ------------------------ DATEDIFF(ARGUMENTS) TIMEDIFF(ARGUMENTS) [Rest of description to be added here] NEED EXAMPLE DATEDIFF() and TIMEDIFF() were added in MySQL 4.1.1. ------------------------
DATEDIFF
when I, SELECT xx,stamp,xx FROM my_table WHERE DATEDIFF(CURDATE(),DATE(stamp)) <1 I get a syntax error... at the (CURDATE(),DATE(stamp)) I fail to see what is wrong with it. I am on 4.0.25
DATEDIFF
Considering I have a table named business where I store advertisementes of business to sale. Each advertisement belongs to an advertisement category wich haves different timelimits (10 days, 20 days, 30 days....) to expire counting from de date it's published. Why does the following query work perfectly in MySQL 5.0 and not in MySQL 4.1.18 ? How could I do for it to work? SELECT business.field, count(business.field) FROM business, advertisements WHERE business.advertype=advertisements.IDAN AND (DATEDIFF(CURDATE(), business.publish_date)<=advertisements.timelimit OR business.advertype=6) AND business.situation='1' GROUP BY business.field;
Datediff
calculation of number of hours i am using with sqlserver in this way SUM(DATEDIFF(hour, dbo.PMSDeliverableLogging.StartDateTime, dbo.PMSDeliverableLogging.FinishDateTime)) AS efforttilldate same task i wanna perform in MySQL it is supporting datediff,sum n hour but how i can get sum of hours between two dates.
DateDiff() Function
I am trying to use the MSSQL function DateDiff('m', date1, date2) in MySQL but mysql do not support the type 'm' or 'd' or 'yyyy'. I do not want to receive the datediff value as a SELECT field e.g. "SELECT datediff('m',dateofbirth,'2005/06/23') from Dependant WHERE TranID = 3068"
Datediff Alternative
I am using this query update bookings set num_days =(select datediff(course_end,course_start) as num_days); which works fine locally as my version is up to date. My webspace is running an earlier version of mysql. Is there any way of changing this to run on an earlier version of mysql.
DATEDIFF In MySQL 4.0
I need a DateDiff function in 4.0! But it wasn't added until 4.1. Does anyone know of what they used before 4.1 came around?
DateDiff Syntax And Use
I want SQL to tell me the numbers of days between a selected collum and today. From what I've read on the web it SHOULD be something like this select *, DATEDIFF('day', renewal_date, getDate()).... I've also tried to get it to work using NOW(), but surrounding renewal_date and getDate with DATE(). It keeps telling me I have a syntax error around 'day', renewal_date, getDate() now it gets 1 step more complicated after I get this to work, What I really need is instead of using all the renewal_date's I need MAX(renewal_date). Will this complicate the matter further?
Datediff Replacement In MySQL
here is my table create table dailyregister ( recordid int, SignedIn datetime, SignedOut datetime TotalTime ???) TotalTime is calculated upon request of the operator and it should be equal to subtracting SIgnedOut - SignedIn. What datatype is best suited for the job? I tried datetime as well but I only get 0000-00-00 00:00:00 results. I need to get the time difference between those two fields (in seconds or minutes) and I found out that datediff ()function only works in MySQL 4.1.
Inserting Result Of Datediff Into A Field
I am trying to get the output of a datediff query on a recordset to update a field in the same record. The following select * from bookings join (select datediff(course_start, course_end) as num_days from bookings where personid >= 1) as dt; appends another field num_days onto the bookings table, where the field already exists. I wish to update the field num_days in the table not put another field. I know that joining them is not the way to go, but this is the only way I got the correct result.
Include A Table Into Another
whether this is possible straight inside the database. On this new website i 'm working on, there are projects, and there is a news section. Each news article will belong to one of the projects, or to 2 other categories ("General" - "website-related"), possibly more in the future. I'd like to keep the "projects" table strictly for projects, so i was wondering if it would be possible to have another table "news_categories" contain the "projects" table at all times. If not, i guess i can unify the two when querying the database_
Trying To Include A Character
im trying to execute this statement in mysql but it doesnt seem to work. update product set Features1 = 'player's battle plan.' where ProductID = '0001'; i think there is a problem with the ' character. is there a way around this? i need the above statement to work.
Include The Primary Key In The Query
I would like to know if it is possible to include the primary key in a query without knowing it's name, for example: SQL SELECT * FROM `table` WHERE PRIMARY KEY = 5; ...for example, but that doesn't appear to work (error in MySQL syntax). I've tried changing "PRIMARY KEY" to things like INDEX, etc., but nothing appears to work. Is what I'm after actually possible, or do I need to get the name first?
Include Any Chars From [0-9] In Like Query
Im trying to write a like query: select * from table1 where column1 like 'abc[0-9]%' (I realize this syntax isnt correct) I want to include any chars from 0-9 in that spot... Does anyone know how to do this?
Database Connectin With An Include
I have used the following statement to connect to my database, and when I run a debug I am getting the following error: Fatal Error: Call to undefined function mysql_connect() in c:/www..... This is how it shows in the various files: <?php include_once "myconnect.php"; /* WorkOrder.php */ ?> The wierd thing is that even though I get the fatal error, the connection to the database still works and the data is uploaded to the database. I am getting this error on every screen that has this include. Here is the info in the file myconnect.php <?php // YOU NEED TO CHANGE THE CONTENTS OF THE values of variables given in single quotes //CONFIGURATION SECTION STARTS /// $servername='localhost' ; // Replace this 'localhost' with your server name $database_username='root'; // Replace this with your username $database_password=''; // Replace this with your password $database_name='ge'; // Replace this 'db' with your database name // CONFIGURATION SECTION ENDS //// mysql_connect($servername,$database_username,$database_password); mysql_select_db($database_name)or die(mysql_error()); ?>
Include Files In Mysql
I have downloaded the free version of QT and build a graphical shell with QT designed. This runs fine after a compilation with VC++ 6.0. Now I want to add mysql-functions by linking with a mysql lib-file. But this didn't work at all. When I include mysql.h without any mysql-code in my program I get this errormessage: c:mysqlincludemysql_com.h(116) : error C2146: syntax error : missing ';' before identifier 'fd' This seems normal as the compiler didn't have a clue what my_socket is in line 116 mysql_com.h. my_socket fd; /* For Perl DBI/dbd */ After some research I found this in my_global.h that now is included: typedef int my_socket; /* File descriptor for sockets */ But now this errormessage appears: c:mysqlincludemy_global.h(420) : error C2040: 'pchar' : 'int' differs in levels of indirection from 'char *' Why aren't all include-files independent of each other and include the files they need? This was how it works when I made programs for Amiga and it works great.
Need To Include Time With The Date
I have a table called 'date_accessed' ... When I query that table for the date, how do I include the time along with it? Here is my query: SELECT user_agent, ipaddress, date_accessed FROM access_tracker;
Function Include() Failed!
I stored some variables in a config.php file, and tried to include it in user.php (same dir). The code is very simple: <?php include("config.php"); ... ?> but the variables in config.php are not available directly.
Dbconnect Include File
Is it best to have the php file that contains all of your dbconnect information in the directory before your htdocs (public_html etc) directory. I had a copy there that I linking to useing ../connectfile.php but some of my connections didn't work and I put it in the main htdocs and it seemed to fix the problem. But is it a security issue? People shouldn't be able to see the info inside because it is php so all they would see is what is echoed to display in a webpage.
Include Multiple Columns
I have a table with these fields: id - account - ip - data what I want to do is select only unique ip, but also include the 'data' field in the result so that I can print the unique ip along with the associated data .. is this possible?i tried 'select distinct ip,data from table' but that returns duplicate ips.
SQL Query To Include Count From Associated Table
I am having a tough time coming up with the sql for the statement but the long and short of it is this: Two Tables: Table 1 is a group - Table 2 is a list of items that belong to a group from table 1. I want to query all (*) information from table 1 AND get the count of the number of associated items from that group from table 2 in that same query.
Alter Table To Include Fulltext Indexes
I am trying to make a search page for a database of articles. I am going to use fulltext indexes on the table to make the search faster and so that I can order results by relevance. Here is my table: ARTICLES - id (int, auto increment, primary key) - authors (varchar) - title (varchar) - year (int) - keywords (text) I want the users to be able to choose (via a dropdown box) whether they want to search by author, title, OR keyword. Not all of them at the same time. So, some example select statements would be: SELECT * FROM articles WHERE MATCH (authors) AGAINST ('Smith'); SELECT * FROM articles WHERE MATCH (title) AGAINST ('Computer'); So how do I alter the table to include the Fulltext indexes? Do I do one fulltext like this: ALTER TABLE articles ADD FULLTEXT my_ft (authors, title, keywords); or do I need to do seperate alters like this: ALTER TABLE articles ADD FULLTEXT my_ft1 (authors); ALTER TABLE articles ADD FULLTEXT my_ft2 (title); ALTER TABLE articles ADD FULLTEXT my_ft3 (keywords);
ORDER BY WHERE + Include Rest Of Table Or ORDER? Possible?
I need to create some SQL that when run returns all the rows which a column is equal to number that has been specified, but then the query needs to return the rest of the rows in the table. How could this be done? is it even possible? Is their order syntax that could do this better?
Select Distinct And Include Non-distinct Columns
I have a publication table that tracks the products assigned to various publications. I want to select all of the distinct products, based on product_ID, assigned to a specific publication but I also want to return additional columns that do not need to be distinct. If I use the following select: Select distinct publication.product_ID, publication_ID.code, publication.region from publication where publication_ID = '12' I would get a list showing the three columns that I want to see which are product_ID, publication_ID and region for publication 12 but I get too many items as the distinct function means that all three of these columns must be distinct and I only need the product_ID to be distinct. So how do I find all of the distinct product_ID but also show other columns such as region? Do I need to do this with some kind of self-join?
REQ: MySQL 4.0 Equivilent Of "DateDiff("m", Date, Now())=1"
I have a query that works in the rest of the SQL world "SELECT invoice.*, invoice.Date FROM invoice WHERE (DateDiff("m", Date, Now())=1);" which will give me all of last month's invoices. However it doesn't work with MySQL 4.0. While "SELECT Invoice.* FROM invoice WHERE (Month(Invoice.Date) = ((Month(Now()))-1))" Is a close substituent, it will blowup in January. Anyone have an equivalent expression for MySQL 4.0?
|