function with dates to compare?
Hi all
in my test examples, which must extend, problem start by employees who start working
previous year (2014, 2013...) more months then sys - 10 month and day to start working more then 28 large
all other dates are working fine.
At this point I've seen like this:
SELECT SUM ((extrait (an (SYSDATE))-extract (year DATE_OF_BEGIN_WORK))) as the year.
SUM (abs (extract(month from SYSDATE)-extract(month from DATE_OF_BEGIN_WORK))) as month,
SUM (abs (extract(day from SYSDATE)-extract(day from DATE_OF_BEGIN_WORK))) as day, group employ_id employ_id table_a where active = 1
are there solutions for creating features that compare the dates in the table:
table_a have colum DATE_OF_BEGIN_WORK compare with sysdate
case 1:
months from the date of start to work > sysdate current months and days of the date to start work > current sysdate day and date of start working < sysdate year then
(extract (YEAR sysdate)-extract (YEAR DATE_OF_BEGIN_WORK));
(Excerpt extracted from (DATE_OF_BEGIN_WORK months) - (sysdate month));
(extract (DATE_OF_BEGIN_WORK days) - excerpt (sysdate days));
case 2:
months from the date of starting work < sysdate current months and the days of the date to start work < current sysdate day and date of start working < sysdate year then
(extract (YEAR sysdate)-extract (YEAR DATE_OF_BEGIN_WORK));
((sysdate sysdate months) extract - extract (DATE_OF_BEGIN_WORK month));
((sysdate day) extract - extract (DATE_OF_BEGIN_WORK days)) + 1;
case 3:
months from the date of start to work > sysdate current months and days of the date to start work > current sysdate day and date of start working < sysdate year then
(extract (YEAR sysdate)-extract (YEAR DATE_OF_BEGIN_WORK))-1;
((extract(month from DATE_OF_BEGIN_WORK)-12) - extract (DATE_OF_BEGIN_WORK month));
(extract (DATE_OF_BEGIN_WORK days) - EXTRACTED (LAST_DAY DATE (DATE_OF_BEGIN_WORK)) + extract (sysdate days)) + 1;
no idea how to solve this problem with the functions will be very useful
concerning
Gordan
It seems you are trying to re - invent most of date mathematics that Oracle has obtained already integrated into it. You'll just put in trouble, especially when there are leap years etc.
How about something like this?
SQL > with (id, dt) t (select 1, to_date('02/06/2010','MM/DD/YYYY') of all the double union)
2 Select 2, to_date('11/29/2001','MM/DD/YYYY') of all the double union
3 select 3, to_date('02/06/2011','MM/DD/YYYY') of all the double union
4. Select option 4, double to_date('10/10/2011','MM/DD/YYYY')
5 )
6 --
7. end of test data
8 --
9 select id, dt
10, floor (months_between(sysdate,dt)/12) years
11, floor (mod (months_between (sysdate, dt), 12)) months
12 - day be ambiguous because of the number of days in a different month
13. you could design your own algorithm to give the desired results, but it is a good approximation
14, floor (sysdate-(add_months (dt, floor (months_between (sysdate, dt))) as dys
15 t
16.
ID DT YEARS MONTHS DYS
---------- ----------- ---------- ---------- ----------
1-6 FEBRUARY 2010 5 8 22
2 29 NOVEMBER 2001 13 10 29
3-6 FEBRUARY 2011 4 8 22
4-10 OCTOBER 2011 4 0 18
4 selected lines.
Tags: Database
Similar Questions
-
How to use the TRUNC function with dates in the expression builder in OBIEE.
Hello
How to use the TRUNC function with dates in the expression builder in OBIEE.
TRUNC (SYSDATE, 'MM') returns 1 July 2010"where sysdate is July 15, 2010 ' in SQL. I need to use the same in the expression builder in the logical layer mdb column.
Thanks in advanceUse it instead:
TIMESTAMPADD (SQL_TSI_DAY, (DAYOFMONTH (CURRENT_DATE) *-1) + 1, CURRENT_DATE) -
How to use the aggregate with Date function
Hi all
I have a Group date is it possible of Max and Min to date.
I tried like this but its out errored <? MIN (current - group () / CREATION_DATE)? >.
I also tried this, but it does not work
<? xdoxslt:minimum (CREATION_DATE)? >
Is it possible to use the function of aggregation with date values.
Thanks and greetings
SrikkanthYou can use
Ensure that the "date" is in canonical format -
Mathematical functions with input/output error
Please refer to the attached picture. Where do you find these mathematical functions with input/output error? I saw these in response to a message.
I think they appear when you connect a waveform or dynamic data type. Since I rarely use these data types (just give the table!), I'm not positive.
Lynn
-
Problems with date calculation
I have a java (and much more far vb) background and it seems that I'm really dependent functions for date calculations. I'm trying to do a few things, but have not been able to accomplish them.
I do not have
Calendar.add()
I briefly contemplated an add function by converting into long then do the calculation and returns a new calendar object, but the problems with this approach comes flourishes as soon as I started. Just trying to find out if a date was yesterday was me banging my head against the wall.
Any help please?
I wrote this, but I don't know if there is a simpler method, go to this issue the wrong way, etc.
public static boolean isYesterday(Calendar c) { Calendar today = Calendar.getInstance(); int newDay = today.get(Calendar.DAY_OF_MONTH); if (newDay == 1) { //get last day of previous month int newMonth = today.get(Calendar.MONTH); int newYear = today.get(Calendar.YEAR); /* If jan 1, get dec of last year */ if (newMonth == 0) { //Java Calendar.MONTH is zero-based newMonth = 11; newYear -= 1; today.set(Calendar.YEAR, newYear); } today.set(Calendar.MONTH, newMonth); newDay = DateTimeUtilities.getNumberOfDaysInMonth(newMonth, newYear); } else { newDay -= 1; } today.set(Calendar.DAY_OF_MONTH, newDay); return DateTimeUtilities.isSameDate(today.getTime().getTime(), c.getTime().getTime()); }
'convert to tz to the device.
I recommend that stick you with using UTC for everything. If you want to display to the user, then a DateField will convert the hour UTC to local time. SImpleDateFormat.formatLocal will also print you long time UTC to local time. So I recommend that you do not have to convert once at the local level.
Remember that System.currentTimeMillis () is time not UTC/GMT.
Of course, that's a good advice or not depends on your app.
I'm not aware of any third-party code that helps, I reinvented wheels square to all my treatment to date. But I never really looked at.
About your code, assuming that c calendar uses the local time zone, so I think that the code works.
-
How do I add 7 days to a date and compare it to the current date in a cfquery?
I have classes that are no longer active once after the date of the class. However, the class should be displayed for seven days more in the backend. I tried to use the script below to get there, but I get an error "Variable DATE is not defined." I'm going in the right direction or is there a better way to do this?
< name cfquery = "getClasses" datasource = "#application.dsn #" >
Select *.
(break the classReg INNER JOIN classReg.classID = classes.classID) INNER JOIN instructors ON classreg.instID = instructors.instID
<!-adding seven days to the date of the class (date) by comparing the current date->
where #DateFormat (DateAdd (would be ', 7, date), 'yyyy-mm-dd') # > #DateFormat (now (), 'yyyy-mm-dd') #.
< / cfquery >
where #DateFormat (DateAdd (would be ', 7, date), 'yyyy-mm-dd') # > #DateFormat (now (), 'yyyy-mm-dd') #.
As Coldfusion said you, quite rightly so, he knows no variable called "date". You're in a request and, apparently, 'date' is a column name. So use the SQL functions instead of Coldfusion functions.
In MySQL, the appropriate where clause is:
WHERE DATE_ADD (date, INTERVAL of 7 DAYS) > CURDATE)
In SQL Server, the appropriate where clause is:
WHERE DATEADD(day,7,date) > GETDATE()
---------------------------------
Afterthought: I would rename the column 'date', as it is a reserved word in some database management systems
-
Working with date and time of the request for help from acrobat JavaScript...
This coming from
Working with date and time in Acrobat JavaScript (part 1 of 3)
The following code adds five days to the current date, and then prints the new date in the console window.
Get the date and time
var rightNow = new Date();
Get the value of millisecond
Article date
var msRightNow = rightNow.getTime ();
Calculate in milliseconds, of 5 days
5 days x 24 hours/day x 60 min / h x 60 s / min x 1000 ms/s
Challenge of var = 5 * 24 * 60 * 60 * 1000;
Do the calculation of var CFAbsoluteTime = msRightNow + challenge;
Create a new Date from the calculated value
var theNewDate = new Date (finalTime);
In the actual work on a form code, you'll want to place the
the object of a field value. But since this is test code, we will
Print the result to the Console window (great for debugging)
Console.println ("5 days from now is:" + theNewDate.toString ());
The foregoing is the exact code (cut and paste)
The error I get here is;
ReferenceError: theNewDate is not defined
1:Console:exec
undefined
To get the "undefined" question a lot... it seems to me, learn to distinguish the undefined 'of type' undefined 'variable' and undefined 'value '.
in this case 'theNewDate' seems to be defined as a variable equal to the current date plus 5 days... BUT I am now "educated" enough to 'see' Why am I getting the error...
Any thoughts... Any who...
You need to highlight all the text that you want to run.
You have not set the rightNow variable before you can apply a method to the variable.
You can just add a new variable as msRightNow name. Why not use rightNow.
Executes the code that you provided with a new departure of Acrobat, I get the following error messages:
rightNow.getTime is not a function
1:Console:exec
TypeError: rightNow.getTime is not a function
1:Console:exec
undefined
What you are showing probably works because your previous attempts have left behind them a variable "rightNow" and as long as you do not have the object of time date change too much, you will not notice the error.
Cleaning of your code:
get the number of milliseconds of the date object.
rightNow var = (new Date()) .getTime ();
define 5 days in milliseconds;
Challenge of var = 5 * 24 * 60 * 60 * 1000;Add 5 days to the value of this moment and assign the result to the last time;
var CFAbsoluteTime = rightNow + challenge;convert finalTime value in a date object.
var theNewDate = new Date (finalTime);display the result;
Console.println ("5 days from now is:" + theNewDate.toString ());Have you tried the code that I provided, it is another way to add days to the date object.
-
How can I work with dates?
I tried several formcalc and javascript methods, but none of them have worked for me so far. What I want to do is take the current date and extract the month and year. Then, I'll use these to test the function of other values. An alternative is to build dates and compare them to the current date. This date may be changed by the user after the form is displayed.
In the code of pseudo-device it would look like this:
currently on the minimum wage - current event is initialize
MonthYear field is initially set to the current date, but can be changed by the user
requiring that to happen again.
var curDate = MonthYear;
var prior10Date = ' 01/07/2010;
var prior09Date = ' 01/07/2009';
var minWage = 8.25;
If (curDate < prior10Date) then
minWage = 8.00;
If (curDate < prior09Date) thenminWage = 7.75;
this.rawValue = minWage;
Ahhh sorry, I didn't explain fully. HelperFunctions is just a script object (right click on the node root the form and say "insert a script object".) HelperFunctions, it's just what I named it. You could call Jerry if you want) it's a bit like a javascript (.js) file where you can write a whole bunch of javascript functions just using as a reference anywhere on the form. So if you have several fields that requires a formatted date of 01/09/2010 to September 1, 2010, you can do this by using a javascript function that you create. For example:
function convertDate (sDate) {}
var month = sDate.substring (0, 2);
var day = sDate.substring (4, sDate.lastIndexOf("/"));
year = sDate.substring(sDate.lastIndexOf("/")+1 var);
var monthSpelledOut = spellMonth (month);
Return monthSpelledOut + "" + day + ', ' + year;
}
function spellMonth (month) {}
{Switch (month)}
case 1:
return to "January";
break;
case 2:
return "February";
break;
...
case 9:
return "September";
break;
....
}
}
so now, no matter where in our form, we call convertDate (...) and pass on the date of our chain.
Summary:
A script object is just a collection of javascript functions to support you can call anywhere in your form by using the syntax:
scriptObjectName.functionName (parameters);
You can name the scriptObjectName everything that you want, (I chose HelperFunctions), and functionName may be something meaningful to you (I chose newDate() and setDate (mm, dd, yyyy);
You will see in the area of the StateMinimumWage, the word is HelperFunctions.newDate () that goes to the HelperFunctions script object and calls the newDate() function returns the current date for me.
-
Overload function "value data" problem on DataGrid Renderer button
Hi all, I hope it is something simple.
I have a class that extends the mx.controls.Button mx.core.IDataRenderer and implements. I need to set the icon of the button whenever the Data property has the value of the data grid. My problem is that my set/get overloaded function of data are never called (I reinforced with the debugging code). Instead the set/get in Container.as functions (3.4 the Flex SDK kit) called.
Here's the Basic code:
exportButtonRenderer.as package controls
{
import flash.events.Event;
import flash.events.MouseEvent;
Import mx.controls.Button;
Import mx.core.IDataRenderer;
Import mx.controls.dataGridClasses.DataGridListData;
Import mx.controls.listClasses.BaseListData;
Import mx.events.FlexEvent;
Import mx.controls.Alert;
Import model.descriptors.compDescriptor;
Import events.exportClickedEvent;
public class exportButtonRenderer extends button implements IDataRenderer
{
Embed your icons
[(Embed(source='/assets/icons/export.png')]
[Bindable]
public static var imageExport: Class;
[(Embed(source='/assets/icons/blank.png')]
[Bindable]
public static var imageBlank: Class;
public void exportButtonRenderer()
{
Super();
}
private var _listData:DataGridListData;
override public function get listData (): BaseListData
{
Return _listData;
}
override public function set listData(value:BaseListData):void
{
_listData = DataGridListData (value);
}
private var _data:Object;
public override function get data (): Object
{
return _data;
}
override public function set data(value:Object):void
{
_data = value;
}
override the clickHandler(event:MouseEvent):void function
{
super.clickHandler (event);
}
}
}Now I know that I am using the Flexlib TreeGrid and not a standard DataGrid but when I trace through all the code all code firing the set/get functions is in any case the DataGrid control.
Here is the my def grid in my main application mxml:
Header 1 < flexlib:TreeGrid
ID = "MKTXGrid".
dragEnabled = 'false' sortableColumns = 'false' showRoot = "false".
(disclosureClosedIcon="@Embed(source='/assets/icons/arrow_right.png')".
(disclosureOpenIcon="@Embed(source='/assets/icons/arrow_down.png')".
(folderOpenIcon="@Embed(source='/assets/icons/psd.png')".
(folderClosedIcon="@Embed(source='/assets/icons/psd.png')".
Click = "MKTXGrid_clickHandler (Event)" "
doubleClickEnabled = "true" doubleClick = "MKTXGrid_doubleClickHandler (event)" left = "0" right = "0" top = low "0" = "16" > "
< flexlib:columns >
< flexlib:TreeGridColumn dataField = "Name" headerText = "Name" minWidth = "200" width = "200" editable = "true" / >
< mx:DataGridColumn dataField = 'ExportName"headerText ="Export Name"/ >
< mx:DataGridColumn dataField = "Export" headerText = "Export" width = "50" minWidth = "20" resizable = "false" >
< mx:itemRenderer >
< mx:Component >
< mx:Box horizontalAlign = "center" width = "100%" verticalScrollPolicy = "off" horizontalScrollPolicy = "off" >
(< contrôles: exportButtonRenderer label = «Exporter» icon="@Embed(source='assets/icons/export.png')" width = "12" height = "12" useHandCursor = "true" >
< controls: Click >
<! [CDATA]
Import events.exportClickedEvent;
var e:exportClickedEvent = new exportClickedEvent();
e.itemData = data;
dispatchEvent (e);
[]] >
< / controls: Click >
< / controls: exportButtonRenderer >
< / mx:Box >
< / mx:Component >
< / mx:itemRenderer >
< / mx:DataGridColumn >
< / flexlib:columns >
< / flexlib:TreeGrid >
Nothing too special happens.I know it can be done, I've seen examples in the SDK:
Either incidentally, I reinforced with the code in the TreeGridItemRenderer class in Flexlib which works correctly and the class def starts like this:
TreeGridItemRenderer.as import flash.display.DisplayObject;
to import flash.display.InteractiveObject;
import flash.display.Shape;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
to import flash.geom.Point;
import flash.geom.Rectangle;
Import flexlib.controls.TreeGrid;
Import mx.controls.Image;
Import mx.controls.dataGridClasses.DataGridListData;
Import mx.controls.listClasses.BaseListData;
Import mx.controls.listClasses.IDropInListItemRenderer;
Import mx.controls.listClasses.IListItemRenderer;
Import mx.core.IDataRenderer;
Import mx.core.IFlexDisplayObject;
Import mx.core.IToolTip;
Import mx.core.SpriteAsset;
Import mx.core.UIComponent;
Import mx.core.UITextField;
Import mx.events.FlexEvent;
Import mx.events.ToolTipEvent;
Import mx.events.TreeEvent;
Import mx.managers.ILayoutManagerClient;
Import mx.styles.IStyleClient;
SerializableAttribute public class TreeGridItemRenderer extends UIComponent
implements IDataRenderer,
IDropInListItemRenderer,
ILayoutManagerClient,
IListItemRenderer
{...Any help would be great!
It's because you put your component in a box. The DataGrid control is affecting .data property of the box and without code is on your component. You shouldn't really need box. You can override updateDisplayList to Center your button instead.
Alex Harui
Flex SDK Developer
Adobe Systems Inc..
-
Call the function with the arguments in AS3
Hello!
I am a new in Flex development and cannot understand same code convention, im Java programmer.
How I can write correct function in ActionScript, my call call: var goodsWnd:CreateGoodsWindow = PopUpManager.createPopUp (this, CreateGoodsWindow, true) as CreateGoodsWindow;
I want call above function with argument, how do?
Where my class: public class CreateGoodsWindow extends extends TitleWindow
{
public CreateGoodsWindow(data:Object)
{....}
}Using PopUpManager.addPopUp () instead of of createPopUp(). addPopUp takes an object that has already been instantiated:
var createGoodsWindow:CreateGoodsWindow = new CreateGoodsWindow (data);
PopUpManager.addPopUp (createGoodsWindow); -
PL/SQL-function with variable number of parameters
Hello
I want to write an INLIKE function that combines the functions of the po and AS operator.
I want to call it that:
SELECT 1 in the table where INLIKE (column, Motif1, pattern2,...) with a variable count of bosses.
Is there a possibility the java selection button (String... stringArray) to declare or to make, I have to define a function with multiple parameters and default values?
With greetings
FlorianYou don't need to write a function no., you can use regular expressions REGEXP_LIKE...
for example to find all the rows that have % ED % or % LY in them...
SQL> ed Wrote file afiedt.buf 1 with t as (select 'FRED IS SCARED' as txt from dual union all 2 select 'EDWARD IS HAPPY' from dual union all 3 select 'BOB AND TIM ARE ASLEEP' from dual union all 4 select 'JIM AND SALLY DO NOT CARE' from dual) 5 -- 6 -- END OF TEST DATA 7 -- 8 select * 9 from t 10* where regexp_like(txt, '(ED|LY)') SQL> / TXT ------------------------- FRED IS SCARED EDWARD IS HAPPY JIM AND SALLY DO NOT CARE
-
Error: No function with name to_date does exist in this scope
Hai All
insert into dail_att(empcode,barcode,intime,attend_date)
(select r1.barcode, to_date (to_char (r1.bardate, 'ddmmyyyy'): min (r1.bartime), 'ddmmyyyy hh24mi'),)
R1.bardate of the r1.barcode temp_attendance group, r1.bardat);
It is my statement to insert
Here I insert data Dail_att the table Temp_attendance and here R1 is the folder that I stated.
It works very well. More I need to add a column in the Insert EMPCODE IE and I need to
take Empl_barcode.
Table of Empl_barcode consist of fields
Empcode tank
Barcode varchar
Etc.
So I need to include empcode in this statement when I use this in my insert statement
insert into dail_att(empcode,barcode,intime,attend_date)
(selecte.emplcode, r1.barcode, to_date (to_char (r1.bardate, 'ddmmyyyy'): min (r1.bartime), 'ddmmyyyy hh24mi'),)
Temp_attendance R1.bardate, e empl_barcode, where e.barcode = r1.barcode group by
R1. Barcode, R1.bardate, e.emplcode);
I got an error
No function with name to_date does exist in the scope
Any help is highly appericatable
Thanks and greetings
Srikkanth.M
Published by: Srikkanth.M on April 24, 2010 09:26Dear Srikkanth,
First of all, in the table / column you provided and that the corresponding query names there are a large number of spelling errors or incompatibilities. It is very important that you make sure that your question is consistent.We have 'trying to figure out' if Bar_code is anme name or a table column, whence the emplcode column etc.
Take the time to write the question and format, please.
Frame queries and code in a pair of tags {code} without spaces.That said...
update dail_att set empcode=(select emplcode from empl_barcode ,dail_att where bar_Code= barcode); And i have an error ORA-01427: single-row subquery returns more than one row
Let us think about this...
The subquery in your update statement (which is the main request) is(select emplcode from empl_barcode ,dail_att where bar_Code= barcode)
In this query, you want to join empl_barcode table and dail_att on * bar_code = barcode) condition.
Why must you table dial_att in the subquery? You do not have.
Remove dail_att the subquery table.VR
Sudhakar B. -
Hello
I have the following plsql:
So, the problem is, that 'L_RECORD. COL_1"returns dates in the form: jj. MM YYDECLARE TYPE record_t IS RECORD ( col_1 DATE, col_2 VARCHAR2 (7), col_3 VARCHAR2 (1) ); l_record record_t; l_ref_cur dyn_fetch.ref_cur_t; BEGIN l_ref_cur := helper.ref_cur; LOOP FETCH l_ref_cur INTO l_record; EXIT WHEN l_ref_cur%NOTFOUND; ELSIF (LOWER (l_record.col_3) = 'd') THEN DELETE FROM table_new WHERE MY_DATE = TO_DATE (l_record.col_1); DBMS_OUTPUT.put_line ('here it is: ' || l_record.col_1); END IF; END LOOP; CLOSE l_ref_cur; END;
It works very well with most of the files, but it does not find the file with date = 15.08.1930. Then I l_record.col_1 = 15.08.30! Maybe the problem is that oracle is not sure if she should return * 1930 or 2030 *...
So, how can I solve this problem, I want to return the l_record.col_1 * 15.08.1930 *, NOT 15.08.30!
Should I change the definition of the record_t type?
Thank you!Your record definition defines COL_1 as a date, so there is not need to convert a date value in this column.
Remove the TO_DATE() function inside the loop.
-
Use thunderbird on several computers with data on server
I want to use Thunderbird on my network home/office computers with data on a central computer. For the moment, I need to use mozbackup to transfer data from my desktop computer to laptop, which is a pain.
Graeme
As already mentioned, IMAP is the best method, but you can move the profile on the central computer folder and then have TB on each computer pointed to this location using the Profile Manager.
Another method is to copy a profile on a network share and start TB with command line arguments that specify the profile.
3rd point: http://kb.mozillazine.org/Synchronizing_mail_on_two_computers
There is a method of moving just the records of e-mail to another location:
http://KB.mozillazine.org/Moving_your_mail_storage_location_%28Thunderbird%29
-
I updated my iPhone to iOS 9.3 6s today and now my data and wifi are in place. Whenever I try to open an app or send text messages with data it does not at all. And with wifi, it just works. I tried just like turn roaming off and off and other lte but nothing seems to work at all. Can someone please?
I have this same problem too, it really gets me upset
Maybe you are looking for
-
I lost my key for synchronization (html document); . . .
... do I need, can I get it back, and if I can how?
-
How to open a tab in a new window
I remember, but by mistake, it seems, that "in ancient times", there is an option to open a tab in a new window. I can't find this option and I can't find such a topic in the forum so far. It is a very useful option. I use beta FF28 on a 64-bit W7Pro
-
Utility power management Portege A100 has stopped working
The power management utility has stopped working and when I try to save the profile of Laptop/portable power management screen control panel I get a message saying that the power cannot be defined as two revision levels are incompatible. I tried to r
-
5102na HP OMEN: how to disable the audio correction Bang &; Olufsen horrible?
Is there someone who could tell me please how to disable the audio correction Bang & Olufsen? I'm sure that some people like it but I work with audio and I can't really how it changes the sound. I tried to open the Bang & Olufsen sign but I cannot un
-
Problem with reading file xls with text inside
Hi all I have a problem to read the excel (xls) file with the first line containing chains of different length. I wonder how can I skip the first line and continue reading of the second line. Thank you very much.