473,387 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

calculate dates

56
have serval date fields in my table that i need to perform calcualations to bring bring a certain # of items.

Fields:

RptDte Date filed closed always the last date of previous month--- 6/30 for this example
EntryDte Date item was entered into system --could be multiple dates
EffDte Date item was or will be effective.--could be multiple dates


My first critera needs to be

Any items with an EfftDte that is 2 months or prior from RptDte (6/30/2007) that was Entered (EntryDte Field) in May or June (m-1 or m-2) from current month.

Second criteria would be

Any items with an effdate that is 3 months or prior from Rptdte (6/30/2007) that was Entered (EntryDte Field) in June (m-1) from current month.
Jul 5 '07 #1
1 1628
JKing
1,206 Expert 1GB
Give these a try,,, They're in the same order as the criteria you posted. They may need a little tweaking depending if I understood what you're asking correctly or not.

Expand|Select|Wrap|Line Numbers
  1. SELECT Item, rptDate, entryDate, effDate
  2. FROM yourTable
  3. WHERE (([effDate]<=DateSerial(DatePart('yyyy',[rptDate]), DatePart('m',[rptDate])-2,DatePart('d',[rptDate]))) 
  4. And DatePart('m',[entryDate])=Month(now())-1 Or 
  5. DatePart('m',[entryDate])=Month(now())-2);
  6.  
Expand|Select|Wrap|Line Numbers
  1. SELECT Item, rptDate, entryDate, effDate
  2. FROM yourTable
  3. WHERE effDate <= DateSerial(DatePart('yyyy',rptDate), DatePart('m', 
  4. rptDate)-3, DatePart('d', rptDate))
  5. AND DatePart('m' ,entryDate) = Month(Now())-1
  6.  
Jul 5 '07 #2

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

Similar topics

2
by: JP SIngh | last post by:
Hi All I need to calculate the number of working days between the two dates entered on an ASP page. I am not that great a coder in ASP and was wondering if someone can help. Basically the...
5
by: SimonC | last post by:
Help needed for a Javascript beginner. As above in the subject... i need a javascript to run this, but not in the form of a web-page. I want to calculate it between 2 fields in a database that...
3
by: | last post by:
Hello, I am hoping someone else has thought about a date time calculation i need to perform. I would like to be able to calculate the number of "working minutes" between 2 dates, given my...
2
by: Steve | last post by:
Hi all How would I find out the average date when given a bunch of dates? For example, I want to find the average length in time from the following dates:...
1
by: Chris Hill via .NET 247 | last post by:
Hi I'm a jnr developer in need of desparate help. Can anyone point me in the right direction for this problem: I calculate the number of days between 2 user defined dates like this: Dim...
3
by: George | last post by:
Can someone tell me how to calculate the number of weeks between two dates. Your help is appreciated. Thanks, George
6
by: Tom | last post by:
Hello, please help me, I need two write a C++ program that can calculate the number of days between two dates.
3
archulu
by: archulu | last post by:
hai this is archulu. i am new to domapi.now my problem is in my project i am taken 2 domapi datepickers. what i am want Calculate duration between two dates which i am selected in that datepicker. ...
0
by: SuzK | last post by:
I am trying to calculate in VBA in Access 2002 a moving average and update a table with the calculations. Fields in my WeeklyData table are Week Ending (date) ItemNbr (double) Sales Dollars...
5
FishVal
by: FishVal | last post by:
IMHO, the following is not a how-to-do instruction to solve a particular problem but more a concept-proof stuff demonstrating possibilities of SQL. So, let us say the problem is to calculate...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
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...

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.