473,473 Members | 2,262 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Looking for Expression using date conditions.

Here's my dilemma. I am putting together a trend report using
PivotCharts and so the query that I am trying to construct basically
would look at the "Date_Entered" for a record and if the "day" portion
of the Date is <= 15 (ie 1/1/2006 - 1/15/2006) it will populate a temp
column with the actual month and year.

However if the "day" portion of the Date is > 15 (ie 1/16/2006 -
1/31/2006) it will populate a temp column with the following month
(actual month + 1) and year.

This the is the current expression as I have it constructed:

MonthOpened: IIf(Month([date_entered])>9 And
Day([date_entered])<=15,Year([date_entered]) &
Month([date_entered]),Year([date_entered]) & '0' &
Month([date_entered])) Or IIf(Month([date_entered])>9 And
Day([date_entered])>15,Year([date_entered]) & Month([date_entered]) +
1,Year([date_entered]) & '0' & Month([date_entered]) + 1)

Anhy guidance that I can get from any of you Access MVPs woud be
extremely welcome.
Thanks
Marc

May 25 '06 #1
17 1590
I am not an MVP and you should not blindly rely on MVPs!

I will assume from your problem statement that the "day" portion of the
Date in the temp column will be the same as the "day" portion of
Date_Entered.

MonthOpened:IIF(Day([Date_Entered]) <= 15, [Date_Entered],
DateAdd("m",1,(Date_Entered])

You can copy and paste this expression into your query to test if it gives
you what you want. If it does not, explain why and I will give you another
expression based on your reason why it does not.
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
Over 1175 users have come to me from the newsgroups requesting help
re******@pcdatasheet.com

"Mr.Kane" <ka*******@gmail.com> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com...
Here's my dilemma. I am putting together a trend report using
PivotCharts and so the query that I am trying to construct basically
would look at the "Date_Entered" for a record and if the "day" portion
of the Date is <= 15 (ie 1/1/2006 - 1/15/2006) it will populate a temp
column with the actual month and year.

However if the "day" portion of the Date is > 15 (ie 1/16/2006 -
1/31/2006) it will populate a temp column with the following month
(actual month + 1) and year.

This the is the current expression as I have it constructed:

MonthOpened: IIf(Month([date_entered])>9 And
Day([date_entered])<=15,Year([date_entered]) &
Month([date_entered]),Year([date_entered]) & '0' &
Month([date_entered])) Or IIf(Month([date_entered])>9 And
Day([date_entered])>15,Year([date_entered]) & Month([date_entered]) +
1,Year([date_entered]) & '0' & Month([date_entered]) + 1)

Anhy guidance that I can get from any of you Access MVPs woud be
extremely welcome.
Thanks
Marc

May 26 '06 #2
* PC Datasheet:
I am not an MVP and you should not blindly rely on MVPs!

I will assume from your problem statement that the "day" portion of the
Date in the temp column will be the same as the "day" portion of
Date_Entered.

MonthOpened:IIF(Day([Date_Entered]) <= 15, [Date_Entered],
DateAdd("m",1,(Date_Entered])

You can copy and paste this expression into your query to test if it gives
you what you want. If it does not, explain why and I will give you another
expression based on your reason why it does not.

--
To anyone reading this thread:

It is commonly accepted that these newsgroups are for free
exchange of information. Please be aware that PC Datasheet
is a notorious job hunter. If you are considering doing
business with him then I suggest that you take a look at
the link below first.

http://home.tiscali.nl/arracom/whoissteve.html

Randy Harris
May 26 '06 #3
"PC Datasheet" <No****@Spam.Com> wrote in message
news:xC**************@newsread3.news.pas.earthlink .net...
I am not an MVP
and with the way you behave and the amount of wrong information you spout,
it is very unlikely you will be.
and you should not blindly rely on MVPs!


They have far more credibility than you will ever attain. The MVP award is
an annual award from Microsoft that is given to individuals for their
product knowledge and FREE community support. Most of the current Access
MVPs have recieved an annual MVP award since they were first awarded.

John... Visio MVP
May 26 '06 #4
Oh, so you mean *advertising* in your posts will pretty much cause you
never to be given an MVP award????!!!!

(tongue in cheek, of course!)

May 26 '06 #5
The following expression did work,

MonthOpened:IIF(Day([Date_Entered]) <= 15, [Date_Entered],
DateAdd("m",1,(Date_Entered])

however I need the output to be in (YYYYMM) format, that's why my
expression:

MonthOpened: IIf(Month([date_entered])>9,Year([date_entered]) &
Month([date_entered]),Year([date_entered]) & '0' &
Month([date_entered]))

was constructed that way. How can I add the condition (IIF
Day(date_entered)>15, then Year([date_entered]) &
Month([date_entered])+1 to my expression?
Thanks again and I apologize for being picky...

May 26 '06 #6
"Mr.Kane" <ka*******@gmail.com> wrote in
news:11*********************@u72g2000cwu.googlegro ups.com:
Here's my dilemma. I am putting together a trend report using
PivotCharts and so the query that I am trying to construct
basically would look at the "Date_Entered" for a record and if
the "day" portion of the Date is <= 15 (ie 1/1/2006 -
1/15/2006) it will populate a temp column with the actual
month and year.

However if the "day" portion of the Date is > 15 (ie 1/16/2006
- 1/31/2006) it will populate a temp column with the following
month (actual month + 1) and year.

This the is the current expression as I have it constructed:

MonthOpened: IIf(Month([date_entered])>9 And
Day([date_entered])<=15,Year([date_entered]) &
Month([date_entered]),Year([date_entered]) & '0' &
Month([date_entered])) Or IIf(Month([date_entered])>9 And
Day([date_entered])>15,Year([date_entered]) &
Month([date_entered]) + 1,Year([date_entered]) & '0' &
Month([date_entered]) + 1)

Anhy guidance that I can get from any of you Access MVPs woud
be extremely welcome.
Thanks
Marc

First, if you put the year first, you will be able to sort
properly. You code fails to correctly handle dates after Dec 15,
which should fall into the next year.
Working with numbers instead of strings is an advantage in a
case like this, you don't have to worry about zeroes for months
1-9.

MonthOpened: Year([date_entered]*100+
IIF(month([date_entered])=12 and day([date_entered])>15,1,0)
+Month([date_entered])+iif(day([date_entered])>15,1,0)

200606 for today. store as a long integer or convert to a string

--
Bob Quintal

PA is y I've altered my email address.
May 26 '06 #7
"Mr.Kane" <ka*******@gmail.com> wrote in
news:11*********************@38g2000cwa.googlegrou ps.com:
The following expression did work,

MonthOpened:IIF(Day([Date_Entered]) <= 15, [Date_Entered],
DateAdd("m",1,(Date_Entered])

however I need the output to be in (YYYYMM) format, that's why my expression:

MonthOpened: IIf(Month([date_entered])>9,Year([date_entered]) & Month([date_entered]),Year([date_entered]) & '0' &
Month([date_entered]))

was constructed that way. How can I add the condition (IIF
Day(date_entered)>15, then Year([date_entered]) &
Month([date_entered])+1 to my expression?
Thanks again and I apologize for being picky...

Don't apologise to PCD, you are entitled to a correct response.
The man hasn't furnished a correct, relevant answer in the
several years I'v been reading this group.
see my separate response to your question for a solution.
--
Bob Quintal

PA is y I've altered my email address.
May 26 '06 #8
Bob Quintal <rq******@sympatico.ca> wrote in
news:Xn**********************@207.35.177.135:
MonthOpened: Year([date_entered]*100+
IIF(month([date_entered])=12 and day([date_entered])>15,1,0)
+Month([date_entered])+iif(day([date_entered])>15,1,0)

200606 for today. store as a long integer or convert to a string

me bad! I forgot to add some parentheses and to fix month 13.
Remind me to debug first, post after.

MonthOpened: Year([date_entered])*100+
IIf(Month([date_entered])=12
And Day([date_entered])>15,100,0)
+ (Month([date_entered])
+ IIf(Day([date_entered])>15,1,0)) Mod 12
--
Bob Quintal

PA is y I've altered my email address.
May 26 '06 #9
Change to this:

MonthOpened:Format((IIF(Day([Date_Entered]) <= 15, [Date_Entered],
DateAdd("m",1,(Date_Entered])),"yyyymm")
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
Over 1175 users have come to me from the newsgroups requesting help
re******@pcdatasheet.com

"Mr.Kane" <ka*******@gmail.com> wrote in message
news:11*********************@38g2000cwa.googlegrou ps.com...
The following expression did work,

MonthOpened:IIF(Day([Date_Entered]) <= 15, [Date_Entered],
DateAdd("m",1,(Date_Entered])

however I need the output to be in (YYYYMM) format, that's why my
expression:

MonthOpened: IIf(Month([date_entered])>9,Year([date_entered]) &
Month([date_entered]),Year([date_entered]) & '0' &
Month([date_entered]))

was constructed that way. How can I add the condition (IIF
Day(date_entered)>15, then Year([date_entered]) &
Month([date_entered])+1 to my expression?
Thanks again and I apologize for being picky...

May 26 '06 #10
Did the new expression I gave you give you what you wanted?
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
Over 1175 users have come to me from the newsgroups requesting help
re******@pcdatasheet.com
"Mr.Kane" <ka*******@gmail.com> wrote in message
news:11*********************@38g2000cwa.googlegrou ps.com...
The following expression did work,

MonthOpened:IIF(Day([Date_Entered]) <= 15, [Date_Entered],
DateAdd("m",1,(Date_Entered])

however I need the output to be in (YYYYMM) format, that's why my
expression:

MonthOpened: IIf(Month([date_entered])>9,Year([date_entered]) &
Month([date_entered]),Year([date_entered]) & '0' &
Month([date_entered]))

was constructed that way. How can I add the condition (IIF
Day(date_entered)>15, then Year([date_entered]) &
Month([date_entered])+1 to my expression?
Thanks again and I apologize for being picky...

May 27 '06 #11
Bob,

Thank you for the mod to Steve's original expression.

May 30 '06 #12
"Mr.Kane" <ka*******@gmail.com> wrote in message
news:11*********************@j73g2000cwa.googlegro ups.com...
Bob,

Thank you for the mod to Steve's original expression.


Praise and put-down in the same phrase, cool.

Keith.
May 31 '06 #13

Keith Wilby wrote:
"Mr.Kane" <ka*******@gmail.com> wrote in message
news:11*********************@j73g2000cwa.googlegro ups.com...
Bob,

Thank you for the mod to Steve's original expression.


Praise and put-down in the same phrase, cool.

Keith.


I wasn't trying to insult anyone I just used Bob's modded expression
and was thanking him for his time. I appreciate Steve taking the time
to answer my question as well. I'm not interested in jumping into the
fray here.

May 31 '06 #14
Everything looks good, however it seems that the records from Dec 2004
with dates less or equal to the 15th are defaulting to "YYYY00"

ie
record date entered 12/5/2004 = "200400"
record date entered 12/11/2005 = "200500"
record date entered 12/2/2004 = "200400"
This the the active expression being used:
MonthOpened: Year([date_entered])*100+IIf(Month([date_entered])=12 And
Day([date_entered])>15,100,0)+(Month([date_entered])+IIf(Day([date_entered])>15,1,0))
Mod 12

any additonal help would be appreciated

(I'll try and tweak the expression and see if I can resolve the
conflict as well)

May 31 '06 #15
"Mr.Kane" <ka*******@gmail.com> wrote in
news:11**********************@i40g2000cwc.googlegr oups.com:
Everything looks good, however it seems that the records from
Dec 2004 with dates less or equal to the 15th are defaulting
to "YYYY00"

ie
record date entered 12/5/2004 = "200400"
record date entered 12/11/2005 = "200500"
record date entered 12/2/2004 = "200400"
any additonal help would be appreciated

(I'll try and tweak the expression and see if I can resolve
the conflict as well)

MonthOpened: Year([calldate])*100+IIf(Month([calldate])=12 And
Day([calldate])>15,100,0)+(Month([calldate])+IIf(Day
([calldate])>15,1,0)) Mod 12+IIf(Month([calldate])=12 And Day
([calldate])<=15,12,0)

Sorry again for insufficient testing.
--
Bob Quintal

PA is y I've altered my email address.
Jun 1 '06 #16
Bob Quintal <rq******@sympatico.ca> wrote in
news:Xn**********************@207.35.177.135:
"Mr.Kane" <ka*******@gmail.com> wrote in
news:11**********************@i40g2000cwc.googlegr oups.com:
Everything looks good, however it seems that the records from
Dec 2004 with dates less or equal to the 15th are defaulting
to "YYYY00"

ie
record date entered 12/5/2004 = "200400"
record date entered 12/11/2005 = "200500"
record date entered 12/2/2004 = "200400"
any additonal help would be appreciated

(I'll try and tweak the expression and see if I can resolve
the conflict as well)

MonthOpened: Year([calldate])*100+IIf(Month([calldate])=12 And
Day([calldate])>15,100,0)+(Month([calldate])+IIf(Day
([calldate])>15,1,0)) Mod 12+IIf(Month([calldate])=12 And Day
([calldate])<=15,12,0)

Sorry again for insufficient testing.


that one has a bug too.

this seems to work right
MonthOpened: Year([calldate])*100+IIf(Month([calldate])=12 And
Day([calldate])>15,100,0)+(Month([calldate])+IIf(Day
([calldate])>15,1,0))-IIf(Month([calldate])=12 And Day
([calldate])>15,12,0)

--
Bob Quintal

PA is y I've altered my email address.
Jun 1 '06 #17
Thanks again Bob...

Jun 1 '06 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Daniela Nii | last post by:
Hi there, I am looking for a javascript function that someone might have already written to calculate the paid-time-off. Given are the start and end date and time. I need to calculate the...
5
by: JIM.H. | last post by:
Hello, I have this validation expression: ^(?:(?:0?|1)|(?:0?|11)(?!\/31)|(?:0?2)(?:(?!\/3|\/29\/(?:(?:0||)00|(?:\d{2}(?:0||))))))\/(?:0?||3)\/\d{4}$ This is supposed to match MM/DD/YYYY it is...
4
by: yer darn tootin | last post by:
Does anyone know the sort expression for a column that's data has been returned in the format, eg '07 Jul 05'?? The sort expression {..:"dd mmm yy"} doesn't work ( if the column was returned as...
1
by: Sa | last post by:
DB2 V 8.1.6 and DB2 V8.2.4 I'm using a Fact Table and 7 Dimension tables in a MQT definition. create mqt1(col-list) as ( select dim1_desc, dim2_desc, .... dim6_date,
4
by: Josh Soref | last post by:
It seems that windows file systems can have files dated to 1617, and unfortunately if you call _findfirst/_findnext on such a directory, msvcr80d will assert. Is there some provision for...
2
by: Ramesh | last post by:
I have a reguar expression syntax that works fine when used in a RegularExpressionValidation control. If I use the exact same regular expression using System.Text.RegularExpressions.Regex to...
3
by: Zach | last post by:
Hello, Please forgive if this is not the most appropriate newsgroup for this question. Unfortunately I didn't find a newsgroup specific to regular expressions. I have the following regular...
0
by: AMDRIT | last post by:
I am looking for better concrete examples, as I am a bit dense, on design patterns that facilitate my goals. I have been out to the code project, planet source code, and microsoft's patterns and...
10
by: Jonathan | last post by:
Hi all, I have a file consisting fixed width records from which I need to extract only those lines meeting certain conditions. These conditions do change and I find myself recoding/compiling...
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
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,...
1
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
1
muto222
php
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.