473,654 Members | 3,096 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date difference

6 New Member
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
Sep 30 '07 #1
7 2467
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?
Sep 30 '07 #2
rdawadiuk
6 New Member
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
Sep 30 '07 #3
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
Expand|Select|Wrap|Line Numbers
  1. Public Function GetEndOfTheQuarter(dteInput As Date) As Date
  2.  
  3.     Dim intMonth As Integer
  4.  
  5.     intMonth = Int((Month(dteInput) - 1) / 3) * 3 + 4
  6.     GetEndOfTheQuarter = DateAdd("d", -1, DateSerial(Year(dteInput), intMonth, 1))
  7.  
  8. End Function
  9.  
the same as expression in query
Expand|Select|Wrap|Line Numbers
  1. SELECT DateAdd("d", -1, DateSerial(Year([dteYourDate]), Int((Month([dteYourDate]) - 1) / 3) * 3 + 4, 1)) AS dteEndOfTheQuarter FROM tblYourTable;
  2.  
Use DateDiff function to calculate difference between dates.
Sep 30 '07 #4
rdawadiuk
6 New Member
Thank you very much. You saved me
Sep 30 '07 #5
FishVal
2,653 Recognized Expert Specialist
You are welcome.

Best regards,
Fish
Sep 30 '07 #6
missinglinq
3,532 Recognized Expert Specialist
Lovely piece of logic, FishVal!

Linq ;0)>
Oct 1 '07 #7
FishVal
2,653 Recognized Expert Specialist
Thanks, Linq.
Oct 1 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

4
5364
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 calculate days, months, and years. This is not for a college course. It's for my own personal genealogy website. I'm stumped about the code. I'm working on it but not making much progress. Is there any free code available anywhere? I know it...
5
2158
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 10/21/1993
7
8479
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 the Toolbox and then set the Format property appropriately. I have noticed that sometimes the Time format will reset spontaneously to Short Date. I looked at the .rc file and found that the usual form for a Short Date is as follows: CONTROL ...
16
1629
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 get: 2 Years, 3 Months, 1 Week, 3 Days, 14 Hours, 21 Minutes, 33 Seconds. The hardest part of that, the part I cannot figure out, is the Month
6
1673
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 that works out the number of days between the 2 dates as follows... Dim d1, d2 As Date
13
2200
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 getkey(void); void differ_dat(struct date *,struct date *); const int mth={31,28,31,30,31,30,31,31,30,31,30,31};
4
15724
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 which calculated the difference in years and days between two dates, and takes leap years into account? I'm calculating the difference in the usual way, i.e....
3
4152
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 column I have to show difference between Currenttime and date from ItemReceived. How can I do that.
6
9015
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 a way to convert a string like "1/2/2005" in a genuan date object which is needed for calculation. now once this is done I will create a another date object with today = datetime.datetime.now() and then see the difference between this today and...
0
8290
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8815
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8708
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6161
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5622
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2716
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 we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.