dateadd

SQL Query Help: Transforming Dates In A Non-Trivial Way

I have a table with a "Date" column, and I would like to do a query that does the following: If the date is a Monday, Tuesday, Wednesday, or Thursday, the displayed date should be shifted up by 1 day, as in DATEADD(day, 1, [Date]) On the other hand, if it is a Friday, the displayed date should be incremented by 3 days (i.e. so it becom...

SQL Server 2005 Using DateAdd to add a day to a date

How do I in SQL Server 2005 use the DateAdd function to add a day to a date ...

How do I take a day of the year and 'bucket it' into weeks of the year in Microsoft SQL? Used in manufacturing scenarios for material requirements

I have a need to create a gross requirements report that takes how much supply and demand of a item in inventory from a start date onwards and 'buckets' it into different weeks of the year so that material planners know when they will need a item and if they have enough stock in inventory at that time. As an example, today’s date (repor...

Date Math in Reporting Services Expression

I'm trying to add days to a date and then compare to see if it's outside a range to color code a cell. It's not working--I think I may be making a simple syntax error. iif( (DateAdd("d", CInt(Fields!Days.Value), Fields!Date.Value) < Now), "Red", "White") ) ...

MySQL: DATE_ADD

Is there a difference between: SELECT DATE_ADD('2005-01-01', INTERVAL 3 MONTH); and SELECT '2005-01-01' + INTERVAL 3 MONTH; ...

T-Sql 2005 Adding hours to a datetime field with the result within working hours

I have two Datetime fields that I wish to add together. They are in the following format: '01/01/1900 00:00:00'. The main issue with this is that I want the calculation to only include working hours. The working day is between 08:30 and 17:30 and does not include weekends: Also if the first field starts out of the working day or is on ...

Using Parameters in DATEADD function of a Query.

I am trying to us the DateAdd function of SQL in my Query. The problem is when I use a parameter to set the second arguement, the number argument I get an error which will say something like this: Failed to convert parameter value from a Decimal to a DateTime While if I enter it parameterless, i.e hardcode an Int, it works fine. ...

Will PHP DateInterval support decimals to add to a date/time?

According to wikipedia - en.wikipedia.org/wiki/ISO_8601 , it should be possible to do this (assuming PHP supports the full ISO 8601): $date = new DateTime(date('Y-m-d H:i:s', time())); // current time - create date time object date_add($date, new DateInterval("PT".round(2.5,2)."H")); //add 2.5 hours (throws exception unknown or bad form...

How to get week ending date of a given date returned from a DateAdd expression

Not sure how to take my current expression and get the week ending date of the week. My current expression returns the date, one week from today. DateAdd(DateInterval.WeekOfYear, 1, today()) What I want to do instead is return the end date (Saturday) of that week instead. What do I need to add to this expression to get the desired r...

How to use MySql date_add in Nhibernate?

This really puzzled for hours, I searched all over the internet, but got no working solution. Can someone point where the problem is ... thanks ! I created my own dialect class public class MySQLDialectExtended : MySQLDialect { public MySQLDialectExtended() { RegisterFunction("date_add_interval", new SQLFunctionTemplate(...

Subdivide timestamps into 3 timeslots

I have following problem where I have to group different transactions into timeslots. Suppose you have a table with records which contain an entry datetimestamp. These records are created by users (operators) who work in different shifts Shift 1: 5 - 13h // Shift 2: 13 - 21h // Shift 3: 21 - 5h Now I want to have a flexible query whic...