Hi all,
Do me a favour.
I need to calculate the DATEDIFF when we pass the dates dynamiically.
I need query..
9 4470
What is the problem with DATEDIFF function.
Is not it working.
Sorry,i didnt explain the requirement properly!!!
DATEDIFF(dd,SISLS.COLUMN016,SISLS.COLUMN005)/365.
it will get the output.but for a leap year it is not showing properly
Sorry,i didnt explain the requirement properly!!!
DATEDIFF(dd,SISLS.COLUMN016,SISLS.COLUMN005)/365.
it will get the output.but for a leap year it is not showing properly
Instead of hard coding 365 ,you need to find out the number of days in the year and pass the same to the query dynamically.
Instead of hard coding 365 ,you need to find out the number of days in the year and pass the same to the query dynamically.
use it as
DATEDIFF(daySISLS.COLUMN016,SISLS.COLUMN005) >= number of days
or
DATEDIFF(daySISLS.COLUMN016,SISLS.COLUMN005) <= number of days
or
DATEDIFF(daySISLS.COLUMN016,SISLS.COLUMN005) = number of days
if the two dates are of different year, which year would you follow? say one of the date is last year (not leap year) and the other date is this year (leap year), what's the number of days that you will use as divisor?
-- ck
if the two dates are of different year, which year would you follow? say one of the date is last year (not leap year) and the other date is this year (leap year), what's the number of days that you will use as divisor?
-- ck
I WIL FOLLOW THE YEAR OF LEAST YEAR
I WIL FOLLOW THE YEAR OF LEAST YEAR
assuming SISLS.COLUMN016 is the earlier date between the two.try: - DATEDIFF(dd,SISLS.COLUMN016,SISLS.COLUMN005)/(datediff(dd,DATEADD(qq, DATEDIFF(qq,0,SISLS.COLUMN016), 0)
-
, dateadd(ms,-3,DATEADD(yy, DATEDIFF(yy,0,SISLS.COLUMN016)+1, 0))))
or maybe someone already have a function to get the number of days in a year...
-- ck
TRY TO USE THIS -
CREATE FUNCTION [dbo].[ufn_GetDaysInYear] ( @pDate DATETIME )
-
RETURNS INT
-
AS
-
BEGIN
-
-
DECLARE @IsLeapYear BIT
-
-
SET @IsLeapYear = 0
-
IF (YEAR( @pDate ) % 4 = 0 AND YEAR( @pDate ) % 100 != 0) OR
-
YEAR( @pDate ) % 400 = 0
-
SET @IsLeapYear = 1
-
-
RETURN 365 + @IsLeapYear
-
-
END
-
GO
-
How to find out the number of days in a financial year.
suppose from date is sep1st,2006.and to date is aug24th,2009.
the entire range involves financial years.i.e.,
april1st,2006-march31st,2007
april1st,2007-march31st,2008
april1st,2008-march31st,2009
april1st,2009-march31st,2010.
we have to calculate the no.of days of last financial year..
waiting for reply..
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Hans Gruber |
last post by:
Hi all,
I have been struggling with a problem all day, I have been unable to come
up with a working solution.
I want to write a function which takes 2 unix timestamps and calculates
the...
|
by: riki |
last post by:
hello,
i need to calculate num of days between 2 dates...
i get separate parts of dates from html form, then i need to "make" begining
and ending date and calculate difference between them......
|
by: Tony Williams |
last post by:
I have a table with two fields, txtvalue (a number field) and txtmonth ( a
date/time field). I want to create a report that shows the difference in
value between the value in txtvalue in one value...
|
by: Tony Williams |
last post by:
SORRY I know we shouldn't do this but I'm desperate for an answer to this
and the previous post didn't seem to get a response.
I have a table with two fields, txtvalue (a number field) and...
|
by: Carl |
last post by:
Hi,
I have a query that produces an output similar to the sample shown
below. These records are based on certain criteria and a date range
selected from a form. I need to create some kind of...
|
by: Yotam |
last post by:
Hi,
I need some help with JS. I will be grateful, if you can help me out.
I have two date fields (check in, check out) and "number of days"
field.
I want the script to calculate automatically...
|
by: slinky |
last post by:
Anyone know how to calculate the difference between two times
displayed in two textboxes?
I'm starting out with two textboxes: "txtCallTimeBegins" &
"txtCallTimeEnds"
this yielded: 6/7/2007...
|
by: Julius |
last post by:
Hej dudes,
I need to calc the difference between two timestamps / dates ...
For example what i need to calculate:
Date 1: 2007.11.06 - 20:13:04
Date 2: 2007.11.07 - 21:13:04
Difference:...
|
by: krishnakant Mane |
last post by:
hello,
I am strangely confused with a date calculation problem.
the point is that I want to calculate difference in two dates in days.
there are two aspects to this problem.
firstly, I can't get...
|
by: mfaisalwarraich |
last post by:
Hi everybody. I have some problem while calculating time. i have employees who are working on hourly basis. i want to calculate the time. for example if an employee start working at 11:00pm...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |