hi,
I would like to calculate the date difference between two dates using field names which I have in my table.
The field name is " Account opened on" for eg
If the "Account open on" is Jan 5, 2007 the I would like to calculate the date difference between this date and the end of the quarter (March 31 2007) I would like Acess to calculate this difference automatically without me entering the end of the quarter date.
please help
thanks
7 2460 FishVal 2,653
Recognized Expert Specialist
Hi, there.
Do you mean difference between two dates stored in your table or between a date stored in your table and end of the quarter the date belongs to?
The date "Account opened on" is stored in my table and I have to calculate the date difference between it and the quarter it belongs to (this is not stored in my table)
thanks
FishVal 2,653
Recognized Expert Specialist
The date "Account opened on" is stored in my table and I have to calculate the date difference between it and the quarter it belongs to (this is not stored in my table)
thanks
Well.
The following function will return end of the quarter the date belongs to -
Public Function GetEndOfTheQuarter(dteInput As Date) As Date
-
-
Dim intMonth As Integer
-
-
intMonth = Int((Month(dteInput) - 1) / 3) * 3 + 4
-
GetEndOfTheQuarter = DateAdd("d", -1, DateSerial(Year(dteInput), intMonth, 1))
-
-
End Function
-
the same as expression in query -
SELECT DateAdd("d", -1, DateSerial(Year([dteYourDate]), Int((Month([dteYourDate]) - 1) / 3) * 3 + 4, 1)) AS dteEndOfTheQuarter FROM tblYourTable;
-
Use DateDiff function to calculate difference between dates.
Thank you very much. You saved me
FishVal 2,653
Recognized Expert Specialist
You are welcome.
Best regards,
Fish
Lovely piece of logic, FishVal!
Linq ;0)> FishVal 2,653
Recognized Expert Specialist Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Richard Hollenbeck |
last post by:
I'm trying to write some code that will convert any of the most popular
standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan
1908) and compare the first with the second and...
|
by: tamilan71 |
last post by:
Hello All
I have table with following fields:
GroupId VisitDate
1 10/19/1993
1 11/24/1998
2 10/18/1993
2 10/29/1998
3 ...
|
by: Edward Mitchell |
last post by:
I have a number of DateTimePicker controls, some set to dates, some set to a
format of Time. The controls are all embedded in dialogs. I created the
controls by dragging the DateTime picker from...
|
by: Atley |
last post by:
I am trying to get a overall difference on two dates,
I can get the difference in Years, Months, Weeks, Days, Hours, Minutes,
Seconds, no problems...
What I cannot seem to figure out is how to...
|
by: Scott |
last post by:
I have a start date and an end date in my project that is defaulted to the current date at run-time using the following code...
Date1.Value = Now()
Date2.Value = Now()
I then have some code...
| |
by: priyasmita_guha |
last post by:
Here is a program-
/* PROGRAM: To find the difference between two dates */
#include<dos.h>
#include<stdio.h>
#include<conio.h>
#include<process.h>
void valid_date(int,int,int);
int...
|
by: jamesyreid |
last post by:
Hi,
I'm really sorry to post this as I know it must have been asked
countless times before, but I can't find an answer anywhere.
Does anyone have a snippet of JavaScript code I could borrow...
|
by: bbawa1 |
last post by:
Hi,
I have a table which has a field ItemsReceived of type datetime. I
have a grid view which has two columns.
In first column i have to show the data from field ItemsReceived and
in second...
|
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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |