Recordset where date is 90 days or older.
Hello,
I am trying to build a recordset from a MSSQL database of records where c.date is 91 days or older. It's been 3 years since I touched Coldfusion so my code below is a little rusty....
<cfset todayDate = Now()>
<!--- Populate Open Quotes --->
<cfquery name="Quotes" datasource="quote">
SELECT q.qid, q.cdate, q.name, q.region, q.cuid, q.quid, q.status, c.company,
c.sitecity
FROM quote q, customer c
WHERE q.status = 'open' AND q.cuid = c.uniqueid AND q.cdate < (<cfoutput>#todaydate#</cfoutput>-90)
ORDER BY cdate
</cfquery>
Any help on this would be greatly appreciated.....
Thanks In Advance.
Gary
There are a few ways to do it. My preference is to use the DateAdd() function to calculate the date 90 days ago: #DateAdd("d", -90, now())#
Of course that will also include the time as well: 2009-12-21 17:21:00. You can truncate the time (ie convert it to a date only) by using either the CreateODBCDate() function:
WHERE q.cdate < #CreateODBCDate(DateAdd("d", -90, now()))#
... OR by using cfqueryparam with the data type "cf_sql_date"
WHERE q.cdate < <cfqueryparam value="#DateAdd("d", -90, now())#" cfsqltype="cf_sql_date">
Generally cfqueryparam is the better option for databases like MS SQL because a) it uses bind variables to help improve performance b) helps protect against sql injection. It also has some other nice features like the "list" and "null" attributes.
http://www.adobe.com/devnet/coldfusion/articles/sql_injection.html
(<cfoutput>#todaydate#</cfoutput>-90)
BTW: You do not need to use <cfoutput> tags inside a cfquery. There may be exceptions, but generally any #variable# used inside a CF tag will be evaluated automatically (without cfoutput tags).
Similar Messages
-
Client saves files locally to her Win 7 64-bit laptop and they are fine when it comes to the date modifed stamp. On occasion a few of these files each day, when saved to the home directory on the server, get the Date Modified stamp changed. Time is never
the same and can be set for las tweek or - literally - 1990, 2004, 2010, etc. I have seen tech articles talking about the different options for saving the file date based on an embedded image or attachment of some type, but that has been ruled out. And this
is not the local saved file time being modified within the first minute or two of a locally copied file.
Any ideas how a file saved to a network share can randomly and intermittently have the date modified to a much older date? Have scanned for malware as well.... Thanks!Hi
Make sure the server or nas where it's saved is sync'ed with it,s time source, and be sure it's update for the OS's patch.
Regards, Philippe
Don't forget to mark as answer or vote as helpful to help identify good information. ( linkedin endorsement never hurt too :o) )
Answer an interesting question ? Create a
wiki article about it! -
When ever enter the date start date up to next year same date between the days divided into 8 parts
when ever enter the date start date up to next year same date between the days divided into 8 parts
Q1.1 (YYYY) = 1st half of Quarter 1 for year YYYY
Q1.2 (YYYY) = 2nd half of Quarter1 for year YYYY
Q2.1 (YYYY) = 1st half of Quarter 2 for year YYYY
Q2.2 (YYYY) = 2nd half of Quarter 2 for year YYYY
Q3.1 (YYYY) = 1st half of Quarter 3 for year YYYY
Q3.2 (YYYY) = 2nd half of QuarterQ3 for year YYYY
Q4.1 (YYYY) = 1st half of Quarter 4 for year YYYY
Q4.2 (YYYY) = 2nd half of Quarter 4 for year YYYY
Here YYYY depicts the year.
e.g. Q1.2 (2014) depicts the 2nd half of Quarter 1 for year 2014.
The description of these values are explained below.
The table below provides the description about each value:
Quarter Quarter Range Start Date
Q1.1 1 Jan - 15 Feb 1st Jan
Q1.2 16 Feb-31 Mar 16th Feb
Q2.1 1 Apr- 15 May 1st Apr
Q2.2 16 May-30 June 16th May
Q3.1 1 Jul-15 Aug 1th Jul
Q3.2 16 Aug -30 Sep 16th Aug
Q4.1 1 Oct -15 Nov 1st Oct
Q4.2 16 Nov – 31 Dec 16th Nov
The dropdown values in time window needs to be updated as per date entered by the user in the Audit Plan start date and
should display the next four Quarter (each divided in 2 half i.e. Eight values ) along with the year from the selected Audit plan start date.
for eg. If the Plan start date is given as August 10 2013 then the Time window will display the following options:
Q3.2 (2013)
Q 4.1 (2013)
Q 4.2 (2013)
Q 1.1 (2014)
Q1.2 (2014)
Q2.1 (2014)
Q 2.2 (2014)
Q 3.1 (2014)
You can refer to the Table above and look that 10 Aug 2013 falls under the Q3.1 so Time window will display the next next 8 half Quarters ( Total 4 Quarter) till Q 3.1 for the year 2014.Hello,
WITH half_quarters AS(
SELECT ADD_MONTHS(TRUNC(DATE '2013-08-15','Q'), 3*(LEVEL - 1)) hq_start
,1 part
FROM dual
CONNECT BY ROWNUM <= 5
UNION ALL
SELECT ADD_MONTHS(TRUNC(DATE '2013-08-15','Q'), 3*(LEVEL - 1) + 1) + 15 hq_start
,2 part
FROM dual
CONNECT BY ROWNUM <= 5
,ordered_half_quarters AS(
SELECT hq_start
,part
,ROW_NUMBER() OVER (ORDER BY hq_start) r
FROM half_quarters
WHERE hq_start > DATE '2013-08-15'
SELECT 'Q '||TO_CHAR(hq_start,'Q')||'.'||part||' ('||TO_CHAR(hq_start,'YYYY')||')' q
FROM ordered_half_quarters
WHERE r <= 8
ORDER BY r;
Q
Q 3.2 (2013)
Q 4.1 (2013)
Q 4.2 (2013)
Q 1.1 (2014)
Q 1.2 (2014)
Q 2.1 (2014)
Q 2.2 (2014)
Q 3.1 (2014)
half_quarters generates the start dates of every half of a quarter, starting with the begin of the first quarter that contains the sample date.
The next step is to order the dates and to select only those after the sample date.
The last part formats the output and orders the data.
Regards
Marcus -
Hi
How can I to get the max Date in each day in data below , I must to do in unique query
select to_date('1/6/2010 06:29:04','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('1/6/2010 06:29:04','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('1/6/2010 06:28:03','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('1/6/2010 06:27:58','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('1/6/2010 06:27:57','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('1/6/2010 06:27:57','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('1/6/2010 06:27:52','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('1/6/2010 06:27:45','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('1/6/2010 06:12:48','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('1/6/2010 06:12:43','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('1/6/2010 06:12:43','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('1/6/2010 06:12:42','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('1/6/2010 06:12:41','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('1/6/2010 06:12:41','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('1/6/2010 06:09:53','dd/mm/yyyy hh24:mi:ss') DATA from dual UNION
select to_date('31/05/2010 06:39:04','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('31/05/2010 06:38:04','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('31/05/2010 06:37:03','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('31/05/2010 06:37:02','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('31/05/2010 06:36:57','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('31/05/2010 06:36:56','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('31/05/2010 06:27:52','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('31/05/2010 06:27:45','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('31/05/2010 06:12:48','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('31/05/2010 06:12:43','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('31/05/2010 06:12:43','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('31/05/2010 06:12:42','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('31/05/2010 06:12:41','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('31/05/2010 06:12:41','dd/mm/yyyy hh24:mi:ss') DATA from dual union
select to_date('31/05/2010 06:09:53','dd/mm/yyyy hh24:mi:ss') DATA from dual
ORDER BY 1 DESCUsing Oracle 9.2.02
TIAAlso possible if you need all the days bettween your first and last day.
with tab as (
select to_date('1/6/2010 06:29:04','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('1/6/2010 06:29:04','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('1/6/2010 06:28:03','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('1/6/2010 06:27:58','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('1/6/2010 06:27:57','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('1/6/2010 06:27:57','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('1/6/2010 06:27:52','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('1/6/2010 06:27:45','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('1/6/2010 06:12:48','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('1/6/2010 06:12:43','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('1/6/2010 06:12:43','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('1/6/2010 06:12:42','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('1/6/2010 06:12:41','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('1/6/2010 06:12:41','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('1/6/2010 06:09:53','dd/mm/yyyy hh24:mi:ss') DATA from dual UNION all
select to_date('31/05/2010 06:39:04','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('31/05/2010 06:38:04','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('31/05/2010 06:37:03','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('31/05/2010 06:37:02','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('31/05/2010 06:36:57','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('31/05/2010 06:36:56','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('31/05/2010 06:27:52','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('31/05/2010 06:27:45','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('31/05/2010 06:12:48','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('31/05/2010 06:12:43','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('31/05/2010 06:12:43','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('31/05/2010 06:12:42','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('31/05/2010 06:12:41','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('31/05/2010 06:12:41','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('31/05/2010 06:09:53','dd/mm/yyyy hh24:mi:ss') DATA from dual union all
select to_date('28/05/2010 02:09:53','dd/mm/yyyy hh24:mi:ss') DATA from dual
,maxmin as (select trunc(min(data)) mindat, trunc(max(data)) maxdat, trunc(max(data))-trunc(min(data))+1 no_of_days from tab)
,days as (select rownum + (select mm2.mindat from maxmin mm2) - 1 dy
from all_objects ao
where rownum <= (select mm1.no_of_days from maxmin mm1))
select d.dy, (select max(data) from tab where trunc(data) = d.dy) max_time
from days d
dy max_time
28.05.10 00:00:00 28.05.10 02:09:53
29.05.10 00:00:00
30.05.10 00:00:00
31.05.10 00:00:00 31.05.10 06:39:04
01.06.10 00:00:00 01.06.10 06:29:04 -
Converting varchar to datetime where date field is missing
Hello Sir,
i have a column with varchar datatype values like '2013/12','2012/11' where date field is missing. i want to convert it as datetime at runtime so that i can use datetime related function. Is it possible for ms sql server 2008?
thanking you.>> I have a column with VARCHAR data type values like '2013/12', '2012/11' where DATE field is missing. I want to convert it as DATETIME2(0) at runtime so that I can use DATETIME2(0) related function. Is it possible for MS SQL Server 2008? <<
The most important leg on a three-legged stool is the leg that is missing :) A DATE is made up of three fields; YEAR, MONTH and DAY. You gave no business rule for picking the DAY field, so this makes no sense.
Since SQL is a database language, we prefer to do look ups and not calculations. They can be optimized while temporal math messes up optimization. A useful idiom is a report period calendar that everyone uses so there is no way to get disagreements in the DML.
The report period table gives a name to a range of dates that is common to the entire enterprise.
CREATE TABLE Something_Report_Periods
(something_report_name CHAR(10) NOT NULL PRIMARY KEY
CHECK (something_report_name LIKE <pattern>),
something_report_start_date DATE NOT NULL,
something_report_end_date DATE NOT NULL,
CONSTRAINT date_ordering
CHECK (something_report_start_date <= something_report_end_date),
etc);
These report periods can overlap or have gaps. I like the MySQL convention of using double zeroes for months and years, That is 'yyyy-mm-00' for a month within a year and 'yyyy-00-00' for the whole year. The advantages are that it will sort with the ISO-8601
data format required by Standard SQL and it is language independent. The pattern for validation is '[12][0-9][0-9][0-9]-00-00' and '[12][0-9][0-9][0-9]-[01][0-9]-00' in the CHECK constraints.
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
Create recordset join, date = todays date
hi,
i have been trying to create a recordset on my page which joins my clients table to insurance table which is fine.
however i need to be able to show on my page due date = today's date.
so in my insurance table i have a duedate column with data type DATE
i need my recordset query to return duedate=todays date and also show if passed due date?
can anyone help me write this query?
many thanksthanks bregent, the database was helped setup viaa posts on mysql forum and by my understanding of mysql of learning over past year or so.
i have queried using just a simple join statement.
thanks
Date: Mon, 22 Mar 2010 19:36:01 -0600
From: [email protected]
To:
Subject: Dreamweaver Application Development create recordset join, date = todays date
>How can i do a query of all duedates in all tables i
>need to query? is it seperate recordsets?
To query against more than one table using standard SQL you could use a UNION query. MySQL also has functionality to query against multiple tables but I don't use MySQL. But I need to ask why you are storing these due dates in more than one table? Who designed this database?
>also need to display the ones due the week leading up to due date?
>so 7 days before currendate=duedate and also once it passes that i
>need another recordset that displays all the ones that have passed
>currentdate=duedate.
This is all just simple date math. Please use the reference I gave earlier for examples or search the web for MySQL date math.
> -
IPod icalendar dates moved 1 day ahead
I have all my correct dates on my iMac but when they sync to my iPod Touch they move the dates ahead one day. Any clue how to fix this? I don't understand how they are correct on iCalendar and not on my iPod. I have found other posts on this subject but most are all for much older OS issues from a few years ago.
I have a similar problem with my iPod/Calendar. There is a manual work around that worked for me. Seems to be a problem with iSync. Here is more details http://discussions.apple.com/thread.jspa?messageID=1747727�
-
In PDF to Excel conversion dates like 03/12/15 convert to Dec 3rd 2015 not the correct date of Mar 12th 2015 whereas date 03/13/2015 converts correctly as March 13th 2015
Hi DirTech,
Are both of these dates in the same Excel file? If they're in different files, are you choosing the same language for OCR (optical character recognition)?
If they are in the same PDF file, how was that PDF file created? Was it created from a third-party application (rather than an Adobe application)? If it was created by a third-party application, it could be that it wasn't written to spec, and that's why you're seeing some oddities in the PDF > Excel conversion. (See Will Adobe ExportPDF convert both text and form... | Adobe Community.)
Best,
Sara -
How to get the date of first day of a week for a given date
Hi gurus
can any one say me how to get the date of first day(date of Sunday) of a week for a given date in a BW transformations. For example for 02/23/2012 in source i need to get 02/19/2012(Sunday`s date) date in the result. I can get that start date of a week using BWSO_DATE_GET_FIRST_WEEKDAY function module. But this function module retrieves me the start date as weeks monday(02/20/2012) date. But i need sundays(02/19/2012) date as the start date. So it would be really great if anyone sends me the solution.
Thanks
RavHi,
The simplest way would be to subtract 1 from the date date which you are already getting in transformation routine, but instead of doing that subtraction manually which might need bit of errort, you can simply use another FM to subtract 1 from given date.
RP_CALC_DATE_IN_INTERVAL
Regards,
Durgesh. -
Date for first day of current month
How can i get the date for first day of current month ?
select trunc(sysdate,'MM'),to_char(trunc(sysdate,'MM'),'DD'),to_char(trunc(sysdate,'MM'),'Day') from dual;
-
Show data of last day of previous month against any day of current month
Hi,
I have fact table which contains data at date level (we have data for oct-2009 to april-2010). Our requirement is to show data of last day of previous month against any day of current month in obiee 11g. I am facing problem in Feb 2010 its picking data of 28-Jan-2010 instead of 31-jan-2010 and for April its picking data of 30-mar-2010 instead of 31-mar -2010.
Any suggestion ???You're asking to filter your data set to only include rows between:
1) last day of the previous month
2) any day of the current month
This can be achieved with prompting in OBIEE Answers.
last day of previous month = TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)) . The problem is you need to make query work within Oracle's Answer syntax.
In the prompt, select the operator type for your date dimension as 'between' and default to 'SQL Results'.
For the 'last day of previous month' , use the query:
SELECT
case when 1=0 then Time."Fiscal Date" else TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))
end
FROM ENTER_YOUR_PRESENTATION_FACT_FOLDER_HERE
For the current date, use the query:
SELECT
case when 1=0 then Time."Fiscal Date" else CURRENT_DATE
end
FROM ENTER_YOUR_PRESENTATION_FACT_FOLDER_HERE
Another option is to create a last_date_pervious_month variable in the RPD and have that as the default value in your prompt. -
Hi Everyone,
I am new to writing reports (SQL code) for SAP, however I am aware that inside SAP Business One it is necessary to enable System Information (from the View menu) in order to see which tables (and related table attributes / column names) are related to various aspects of the various SAP 'modules' (e.g.: A/R Invoice).
Using an A/R Invoice as an example I can see at the row (or line) level that an item with the description of 'Opening Balance Transfer' is contained in the table INV1, within the attribute (or column) called Dscription.
However not every 'on screen object' shows a table / attribute. For example in the same A/R Invoice if I hover my mouse over the Balance Due field all I see is Form related information.
My question is 'How do I make sense of the Form, Item, Pane, Variable information?', with relation to where data is stored within the SQL database?
Links to online tutorials explaining how this feature of SAP Business One will be much appreciated, along with any personal advice regarding working with this information.
Any (and all) help will be greatly appreciated.
Kind Regards,
DavidHi David,
1.Here I am explaining use of each field except pane
a. Form ---> Used in additional authorization creator
b. Item, column--->Useful in creating Formatted search queries (FMS)
c. Variable --> Some of the field values based on another values. ie. indirect values.
d. INV1---Table name
2. How to get variable?
As per your second attachment, to get balance due ,you need doc total field from OINV table. For example,
SELECT T0.[DocNum], T0.[DocTotal] FROM OINV T0 WHERE T0.[DocNum] = 612004797
Thanks & Regards,
Nagarajan -
I am new to the MAC world but I am very familiar with Lightroom on a PC. This weekend I was weeding out the pics I do not want on my MAC and now I have a ? by all my folders. How do I recover/get back to where I was 2 days ago?
These instructions will help you fix the problem: Adobe Lightroom - Find moved or missing files and folders
-
How to get the date of 60 days before 1999/03/01?
Hi, I have a question about Date and GregorianCalendar here. I have a string "1999/03/01" and I would like to know the date that 60 days before 1999/03/01. What should I do it?
I only went this far:
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
String date = "1999/03/01";
Date day = dateFormat.parse(date);
GregorianCalendar calendar = new GregorianCalendar();
: <--- ??
So, can anyone please tell me what should I do next??
-jxchouPut this in the search box for this forum at the right: add days +date
The first 2 hits are about your question.
The Forum search is your friend... -
How to convert Date format into day in ssrs reports?
Hi
How to convert date format into day?
10/01/2010 as like Monday like that?=weekdayname(datepart("w",Fields!mydate.Value))
-Vaibhav Chaudhari
Maybe you are looking for
-
Black background after update to 10.6.7 or 10.6.8
Hello Community, im new in here and would like to ask for help. My Problem is that when i will update my machine from 10.6.6 to 10.6.7/10.6.8 my backgrounds in Finder and the rest of my OS Control panels are in black so that i can´t use my machine re
-
Apple website doen't recognise the serial number on my iPod Nano
Strange and frustrating! I have a 1st generation iPod Nano. I received an email from Apple about a replacement program for the iPod Nano. I have been trying to check my serial number on the apple website, but it is not being recognised. I took the pr
-
I tried to build version 2.5.16 with the following options: ./buildall.sh prefix=/usr/local enable-perl I got the following message: make[1]: Entering directory `--------/dbxml-2.5.16/dbxml/src/perl/DbXml' PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils:
-
Which is better graphic for iMac 2007 or MacBook Air 2012
iMac use ATI Radeon HD 2600 Pro 256 MB and MacBook Air use intel graphic 5000m so which is better?
-
How to get SD Document Category
Hello Friends, I am not a functional guy and so am having problem in knowing how SD Document Category is related to a customer. I have details like customer, sales organization, distribution channel, division inco terms etc., I have to create a quote