How to calculate the difference between intdate and getdate
Hi,
My requirement is to get the data for all the claims where the difference between transactiondate and getdate() should be less than or equal to 7 which means any claims that happened in the past week.
So, my query would be something like this
select * from claims
where transactiondate-getdate < 8
But my transactiondate is in int format such as 20150331 and getdate would be in the format of 2015-03-31. Can someone please help me on how can i achieve the difference between these 2 date formats in the where clause.
Please let me know if you have any questions or if i am unclear.
Thanks
Hi SqlDev12,
Please find the below condition in your query,hope it would help you
DATEDIFF(DD,CAST(CAST(TransactionDate
AS
VARCHAR)
AS
DATETIME),GETDATE())
< 8
Thanks & Regards,
Praveena.
Similar Messages
-
How to calculate the difference between two dates?
Hello,
I would like to write some code which figures out how many days are between the Date_of_change (which is of datatype DATE, length 7 and of format DD-MON-YY) and the current date today. Then if the difference between Date_of_change and the current date is greater that 30 days for example then I would like to delete that record from the database.
Thanks
DougSomething like this should work:
SQL> select * from emp order by hiredate ;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7934 MILLER CLERK 7782 21-OCT-2005 1300 10
7902 FORD ANALYST 7566 22-OCT-2005 3000 20
7900 JAMES CLERK 7698 23-OCT-2005 950 30
7876 ADAMS CLERK 7788 24-OCT-2005 1100 20
7844 TURNER SALESMAN 7698 25-OCT-2005 1500 0 30
7839 KING PRESIDENT 26-OCT-2005 5000 10
7788 SCOTT ANALYST 7566 27-OCT-2005 3000 20
7782 CLARK MANAGER 7839 28-OCT-2005 2450 10
7698 BLAKE MANAGER 7839 29-OCT-2005 2850 30
7654 MARTIN SALESMAN 7698 30-OCT-2005 1250 1400 30
7566 JONES MANAGER 7839 31-OCT-2005 2975 20
7521 WARD SALESMAN 7698 01-NOV-2005 1250 500 30
7499 ALLEN SALESMAN 7698 02-NOV-2005 1600 300 30
7369 SMITH CLERK 7902 03-NOV-2005 800 20
14 rows selected.
SQL> delete from emp where hiredate < sysdate - 30 ;
10 rows deleted.
SQL> select * from emp order by hiredate ;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7566 JONES MANAGER 7839 31-OCT-2005 2975 20
7521 WARD SALESMAN 7698 01-NOV-2005 1250 500 30
7499 ALLEN SALESMAN 7698 02-NOV-2005 1600 300 30
7369 SMITH CLERK 7902 03-NOV-2005 800 20
4 rows selected.
SQL> -
How to calculate the difference between values in a custom PSObject?
If I have a PSObject (created from an imported CSV) that has data like the following:
date,Total size of files uploaded
03-17-2014 09:08,1293334574547
03-17-2014 09:10,1293335326912
03-17-2014 09:13,1293336523562
03-17-2014 09:14,1293337541156
03-17-2014 09:16,1321031223511
03-17-2014 09:16,1321032156844
This CSV will have lines added to it, so the total number of lines will vary.
Is there a way that two most recently added values and calculate the difference of the "Total size of files uploaded" values?
I have the columns properly cast as datetime and
int64 already using this:
$csv = Import-Csv $csvLocation |
Where-Object { ![string]::IsNullOrWhiteSpace($_.datetime) } |
Foreach-Object {
$_.datetime = $_.datetime -as [datetime]
$_."Total size of files uploaded" = $_."Total size of files uploaded" -as [int64]
$_ }
I tried searching thinking surely there must be someone else who has tried to do this" but I cannot find anything. I am just not sure how to approach this problem. Any help would be appreciated!Assuming all of your records are sequential with the last two being the most recent you could use this:
$csv = Import-Csv $csvLocation |
Where-Object { ![string]::IsNullOrWhiteSpace($_.datetime) } | select -last 2
Foreach-Object {
$_.datetime = $_.datetime -as [datetime]
$_."Total size of files uploaded" = $_."Total size of files uploaded" -as [int64]
$_ }
$Difference = $csv[1]."Total size of files uploaded" - $csv[0]."Total size of files uploaded"
This uses the index of the imported array and just the last two records. Note that this will give a negative value if the total is less in the later record. Hope this helps!
You could also use
| sort datetime -ascending | select -last 2
if they aren't already in order... -
How to tell the difference between 10w and 12w?
We have:
2 iPhone 5s
1 iPad
1 iPad 2
1 iPad (4) with Retina
I know that the iPhones use the smaller 5w charger, but how do I tell the difference between the iPad/iPad 2's 10w charger and the iPad 4's 12w charger? They look exactly the same.
The iPad 4 takes forever to charge, so I want to make sure I am using the 12w - and I don't want to damage the older iPads by accidentally using the 12w.
Thanks!Read the fine print on the charger. My iPad 2 10W charger says 5.1V 2.1A. A 12W charger should have a higher number for A.
You can use the iPad 4 charger on your other devices, without damage, to charge them faster.
~~~~~~~~~~~~~~
The quickest way (and really the only way) to charge your iPad is with the included 10W or 12W (5W on Mini) USB Power Adapter. iPad will also charge, although more slowly, when attached to a computer with a high-power USB port (many recent Mac computers) or with an iPhone Power Adapter (5W). When attached to a computer via a standard USB port (2.5W, most PCs or older Mac computers) iPad will charge very slowly (but iPad indicates not charging). Make sure your computer is on while charging iPad via USB. If iPad is connected to a computer that’s turned off or is in sleep or standby mode, the iPad battery will continue to drain.
Apple recommends that once a month you let the iPad fully discharge & then recharge to 100%.
How to Calibrate Your Mac, iPhone, or iPad Battery
http://www.macblend.com/how-to-calibrate-your-mac-iphone-or-ipad-battery/
At this link http://www.tomshardware.com/reviews/galaxy-tab-android-tablet,3014-11.html , tests show that the iPad 2 battery (25 watt-hours) will charge to 90% in 3 hours 1 minute. It will charge to 100% in 4 hours 2 minutes. The new iPad has a larger capacity battery (42 watt-hours), so using the 10W charger will obviously take longer. If you are using your iPad while charging, it will take even longer. It's best to turn your new iPad OFF and charge over night. Also look at The iPad's charging challenge explained http://www.macworld.com/article/1150356/ipadcharging.html
Also, if you have a 3rd generation iPad, look at
Apple: iPad Battery Nothing to Get Charged Up About
http://allthingsd.com/20120327/apple-ipad-battery-nothing-to-get-charged-up-abou t/
Apple Explains New iPad's Continued Charging Beyond 100% Battery Level
http://www.macrumors.com/2012/03/27/apple-explains-new-ipads-continued-charging- beyond-100-battery-level/
New iPad Takes Much Longer to Charge Than iPad 2
http://www.iphonehacks.com/2012/03/new-ipad-takes-much-longer-to-charge-than-ipa d-2.html
Apple Batteries - iPad http://www.apple.com/batteries/ipad.html
Extend iPad Battery Life (Look at pjl123 comment)
https://discussions.apple.com/thread/3921324?tstart=30
New iPad Slow to Recharge, Barely Charges During Use
http://www.pcworld.com/article/252326/new_ipad_slow_to_recharge_barely_charges_d uring_use.html
Best Practices for iPad Battery Charging
http://www.ilounge.com/index.php/articles/comments/best-practices-for-ipad-batte ry-charging/
Tips About Charging for New iPad 3
http://goodscool-electronics.blogspot.com/2012/04/tips-about-charging-for-new-ip ad-3.html
How to Save and Prolong the battery life of your new ipad
https://discussions.apple.com/thread/4480944?tstart=0
Prolong battery lifespan for iPad / iPad 2 / iPad 3: charging tips
http://thehowto.wikidot.com/prolong-battery-lifespan-for-ipad
iPhone, iPod, Using the iPad Charger
http://support.apple.com/kb/HT4327
Install and use Battery Doctor HD
http://itunes.apple.com/tw/app/battery-doctor-hd/id459702901?mt=8
To Extend a Device’s Battery Life, Get to Know It Better
http://tinyurl.com/b67c7xz
iPad Battery Replacement
http://www.apple.com/batteries/replacements.html
In rare instances when using the Camera Connection Kit, you may notice that iPad does not charge after using the Camera Connection Kit. Disconnecting and reconnecting the iPad from the charger will resolve this issue.
Cheers, Tom -
How to calculate the difference between 2 different times being input.
import java.io.*;
import java.util.*;
public class ClockingInOut
public static void main(String[] args) throws IOException
BufferedReader keyboard = new BufferedReader (new InputStreamReader (System.in));
String input, input1, input2;
int num1, num2, answer;
System.out.println ("\t\t\tEMPLOYEE CLOCKING IN AND OUT SYSTEM!");
do
System.out.print ("\nWould you like to clock in and out? yes (y), no(n), ?: ");
input = keyboard.readLine();
if (input.equals("y"))
System.out.print ("Please enter the hours you clocked in: ");
num1 = Integer.parseInt (input1 = keyboard.readLine());
System.out.print ("Please enter the minutes you clocked in: ");
num2 = Integer.parseInt (input2 = keyboard.readLine());
System.out.print ("Now Please enter the hours you clocked out! ");
num1 = Integer.parseInt (input1 = keyboard.readLine());
System.out.print ("And please enter the minutes you clocked out!: ");
num2 = Integer.parseInt (input2 = keyboard.readLine());
Hi people, i think my coding may be wrong. I would like the user to input the hours and then minutes of the time they clocked in and out of work. and then i want the program to be able to calculate the hours worked and print the mesage in the Command Prompt window.
It's really confusing and hard, please help and provide me with the correct soure code if you can.
Also, like in html how the notepad file has to have the opening and closing brackets, does java coding have something like this.
Please reply. Thank You.hi
check this java class
import java.sql.Time;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class util
public static void main(String[] args) throws Exception
long t1 = getTimeOnlyLong();
Thread.sleeo(2000);
long t2 = getTimeOnlyLong();
System.out.println(differenceBetween2Times(t1,t2));
public static long getTimeOnlyLong()
Date d = new Date();
return d.getTime();
public static String differenceBetween2Times(long l1 , long l2)
long diff = l1 - l2;
System.out.println("differ = " + diff);
Date d = new Date();
d.setTime(diff);
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
return sdf.format(d.getTime());
} -
How to tell the difference between ibook and ibook g4 screens?
Hi, I've got a faulty screen on my ibook g4, and have spent the last month or so trying to find a second hand replacement one.
I recently bought a screen on ebay, but when I received it, it only said 'iBook' on the front, not 'iBook G4' as my current one does. I replied to the seller to complain that he sent me a g3 screen, but he insists it's G4.
Before I take it any further, can anyone confirm whether it is possible that this is actually a g4 screen, even though there is no mention of G4 on it?
Here is a picture(http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&rd=1&item=120281147959&ssPageNam e=STRK:MEWN:IT&ih=002#ebayphotohosting)
Thanks, NickAs far as I have encountered, the 12" screens are cross compatible between the G3 and G4 iBooks. The LCD screens - not the cable harnesses. You can take the LCD from the G3 screen and replace the one from the G4.
Now, with the 14" iBooks, the high end (1.33 and 1.42 GHz models) G4 iBooks use a screen that is not cross-compatible with earlier G4 or G3 models.
So, while you cannot swap the entire screen assembly between the g3 and G4, the LCD panels are largely swappable. The screen bezel and frame are also swappable.
Mad Dog -
How to tell the difference between iphone6 and iPad mini chargers
I Don't know which charger is which. iPhone 6 and ipad mini original. They both have same info on back
Hey Applechele,
Thanks for the question. If I understand correctly, you have 2 chargers that look the same. I would recommend that you read these articles, they may be helpful in troubleshooting your issue.
Using iPad power adapters with your iPhone, iPad, and iPod - Apple Support
Your iPad comes a USB power adapter. You can also use this adapter with your iPhone and iPod.
Charge the battery in your iPad - Apple Support
Identify your USB power adapter
Thanks for using Apple Support Communities.
Have a great day,
Mario -
Calculate the Difference Between two dates excluding weekends and Holidays
Hi,
We need to calculate the difference between the two dates by excluding the Local public holidays (It is global and varies across countries) and weekends should not be included in calculation for a business day in OBIEE.
We have two dates: Open date and close date when ever close date is null we are calculating age based on taking the current timestamp and need to exclude the weekends and Holidays when ever the close date is null.
Ex:
Col1 col2 Total
11/9/2010 2:46:38 PM Null 13
11/2/2010 8:06:26 PM 11/3/2010 5:37:03 PM 1
(In the Total we shouldn't include the weekends,holidays)
Please let me know how to calculate the difference between two dates by excluding the weekends and holidays.
Thanks
Edited by: user10441472 on Nov 22, 2010 3:14 PMYou already asked this question and I answered it...
Re: calculation of Business day in OBIEE -
Calculate the Difference between 2 dates
Please let me know how to Calculate the Difference between 2 dates in Time Management. I have a hire date(U1) and adjusted Service Date(B2)
I need to Find out the number of Years, Days and Months between these 2 dates
Thanks a lot in AdvanceHi Rahul,
You can take a look at the standard function 'HR_HK_DIFF_BT_2_DATES' and see if it suits your need.
Regards.
Francis -
How to get the difference between two HashMaps
i have two HashMaps
HashMap first = new HashMap<Integer,Object>();
HashMap second = new HashMap<Integer,Object>();
How to get the difference between one and two and put the result in the third
HashMap third = new HashMap<Integer,Object>();My bad, difference of course means removeAll():Map<Integer,Object> first = new HashMap<Integer,Object>();
Map<Integer,Object> second = new HashMap<Integer,Object>();
Map<Integer,Object> third = new HashMap<Integer, Object>(first);
third.keySet().removeAll(second.keySet());No loops needed. -
To calculate the difference between timings ( PM - AM )
Hi All,
Can anyone let me know how to calculate the difference between the time.
EG : From time : 23:00:00 pm
To time : 01:00:00 am
instead of 2 hours we are getting 22 Hrs
Thanks in Advance
SathyapriyaHi Priya,
How about using FM: HR_PDC_ADD_24_HOURS
PARAMETERS: p_tim1 TYPE uzeit, " 23:00:00
p_tim2 TYPE uzeit. " 01:00:00
DATA: l_diff TYPE uzeit.
START-OF-SELECTION.
IF p_tim1 > p_tim2.
CALL FUNCTION 'HR_PDC_ADD_24_HOURS'
CHANGING
logical_time = p_tim2.
ENDIF.
l_diff = p_tim2 - p_tim1.
WRITE:/ l_diff.
As you are saying you have 30 fields to calculate, make a subroutime instead of calculating everytimg like:
PERFORM cal_tim_diff USING p_tim1 p_tim2
CHANGING l_diff.
*& Form CAL_TIM_DIFF
FORM cal_tim_diff USING p_tim1 TYPE uzeit
p_tim2 TYPE uzeit
CHANGING p_diff TYPE uzeit.
IF p_tim1 > p_tim2.
CALL FUNCTION 'HR_PDC_ADD_24_HOURS'
CHANGING
logical_time = p_tim2.
ENDIF.
p_diff = p_tim2 - p_tim1.
ENDFORM. " CAL_TIM_DIFF
If it still doesnt help, check the data type of the time fields that you are considering. -
Hi,
I am new to Labview. This question might be a joke to some of you here, but any help would be greatly appreciated. I have a spreadsheet with time stamps and power outputs from a generator. I am supposed to calculate the difference between consecutive time stamps, which will act as a delay for the next power output update that needs to be sent. For example, lets say that I have to following data:
Time Stamp Power Output
11:00:00 AM 3kW
11:00:02 AM 2.9kW
11:00:04 AM 3.2kW
11:00:06 AM 3.1kW
The above data doesn't make any sense, but it is just for the purpose of this question.
So, I have to read 11:00:00 AM and 3kW initially - 3kW is the initial request thatHello
you can simple subtract one time from the other one and so you get the difference. -> Example
Mike
Attachments:
Unbenannt 2.vi 8 KB -
Hi,
I am new to Labview. This question might be a joke to some of you here, but any help would be greatly appreciated. I have a spreadsheet with time stamps and power outputs from a generator. I am supposed to calculate the difference between consecutive time stamps, which will act as a delay for the next power output update that needs to be sent. For example, lets say that I have to following data:
Time Stamp Power Output
11:00:00 AM 3kW
11:00:02 AM 2.9kW
11:00:04 AM 3.2kW
11:00:06 AM 3.1kW
The above data doesn't make any sense, but it is just for the purpose of this question.
So, I have to read 11:00:00 AM and 3kW initially - 3kW is the initial request that is sent. Then I have toRepeated forum post
Please view http://forums.ni.com/ni/board/message?board.id=170&message.id=294435
Regards,
Juan Galindo
Applications Engineer
National Instruments -
1)Now I use Lightrom 5.7 how to upgrade to 6 or CC?
2) What is the difference between 6 and CC version?
3) When I used lightromm 3, I could see in EXIF the distance in meters till the object I took, in the later virsions that function disappeared, it is very sad I am stiil waiting and hope that it would be possibble in the new versions. Or this indication may possible by setting?1)Now I use Lightrom 5.7 how to upgrade to 6 or CC?
Purchase the standalone upgrade from here: Products
Download CC version from here: Explore Adobe desktop apps | Adobe Creative Cloud
2) What is the difference between 6 and CC version?
See this comparison chart: Compare Lightroom versions | Adobe Photoshop Lightroom CC
3) When I used lightromm 3, I could see in EXIF the distance in meters till the object I took, in the later virsions that function disappeared, it is very sad I am stiil waiting and hope that it would be possibble in the new versions. Or this indication may possible by setting?
Rob Cole's ExifMeta plugin displays the Subject Distance field (and much more). Unfortunately, his Web site appears to be down again. He used to be very active here, but he hasn't posted in several months. -
MDX - how to calculate the sales between a certain period and the currentmember with a max date
Hi all,
1)I need to calculate the sales between W1 and the currentmember, but the max date should be W20. How can I solve this in MDX?
MEMBER [Measures].[Q1 act.period to date sales] AS
Sum(
[Date invoice].[Bonus calendar - Week].[Bonus week of year].&[2015]&[1]
[Date invoice].[Bonus calendar - Week].Currentmember
*[CurrentSalesPeriod]
,[Measures].[Sales amount]
This is the measure I have, I need to add the max date is W20.
2)Also, when I calculate the sales between [Date invoice].[Bonus calendar - Week].[Bonus week of year].&[2015]&[40] and the currentmember, for example being [Date invoice].[Bonus calendar - Week].[Bonus week of year].&[2015]&[20],
he calculated the sales between this period. However, in theory this is not possible because W20 < 40. Is there any way I can put a constraint on this that he only calculates the sales if the currentmember is > the start period?
Thanks in advance!Y, you can put a check on to determine if currentmember > start period.
Firstly, your period keys are composite of year and period (indicated by the two ampersands in the fully qualified date above). If your period keys were non-composite (eg 201501) it would be a simple matter of
IIF([Date invoice].[Bonus calendar - Week].Currentmember.properties("key") > [Date
invoice].[Bonus calendar - Week].[Bonus week of year].&[2015]&[1].properties("key"),[Measures].[Sales
amount],null)
There are advantages of having two period attributes on the dimension, one with a fully unique
key and the other with just the period of fy, but that's digressing.
With your composite keys, you could use a calc like the following for the SUM()
Sum(
[Date invoice].[Bonus calendar - Week].[Bonus week of year].&[2015]&[1]
[Date invoice].[Bonus calendar - Week].Currentmember
*[CurrentSalesPeriod]
,IIF([Date
invoice].[Bonus calendar - Week].Currentmember.parent.properties("key") +[Date
invoice].[Bonus calendar - Week].Currentmember.properties("key") > [Date
invoice].[Bonus calendar - Week].[Bonus week of year].&[2015]&[1].parent.properties("key")+[Date
invoice].[Bonus calendar - Week].[Bonus week of year].&[2015]&[1].properties("key"),[Measures].[Sales
amount],null))
Richard
Maybe you are looking for
-
I cannot add a Wi-Fi guest network. Gone to Utilities>Airport Utilities and all I get is an image/browser of my Airport Extreme. Looking for the browser window which has the title Wireless but cannot find anywhere. What am I doing wrong?
-
About xml and null values in 10g
Hi, I have an UCM GetFile webservice component wich receives 4 arguments, two of them are null values (rendition and extraPops), and the xml request generated by obpm is: <GetFileByName xmlns="http://www.stellent.com/GetFile/"> <dDocName>V_123410</
-
How do I create an interactive PDF file in InDesign CS6 with Folio Overlays?
I have been trying to export an interactive PDF file using InDesign CS6. It exports fine, and all the content works except for the Folio Overlays I created. I created two Folio Overlays (one Pan & Zoom and one Scrollable Frame). The overlays work if
-
My MacBook pro refuses to work with my Kodak esp 3.2s?
i have bought a MacBook over a month ago i have got it checked out their are no issues with it what so ever. However the Kodak printer i have tried connecting wireless but still will not work even when i try to use t with a wired connection it still
-
I entered my download digital copy into itunes, it is in my purchase history, but not in my itunes. Help