473,385 Members | 1,320 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,385 software developers and data experts.

Using "MM" Date Format in Query When Data is "M" format

I'm thinking this is easy but can't get it. I have a table with
following:

Table1
Date 1/1/2007

Table2
Type 0107 (This is MMYY of above)

So I'm having trouble using a query to turn the date from Table 1 into
the Type from Table 2. I know when the dates are >=10, I can just use
Left,2 and Right, 2. I don't want to have to put a long condition that
says "If month <10, then use '0'&Left,1, else use Left,2" Though I'd
think this will work, it's a little awkward. Setting the format type
in the query only changes the display, doesn't let me query off of it.
(i.e. format mm/dd/yyyy displays 01/01/2007 but I can't use Left,2 and
get "01" from that.)

Thanks!
Darrell

Jan 5 '07 #1
5 2138
ve***@aol.com wrote:
I'm thinking this is easy but can't get it. I have a table with
following:

Table1
Date 1/1/2007

Table2
Type 0107 (This is MMYY of above)

So I'm having trouble using a query to turn the date from Table 1 into
the Type from Table 2. I know when the dates are >=10, I can just use
Left,2 and Right, 2. I don't want to have to put a long condition
that says "If month <10, then use '0'&Left,1, else use Left,2"
Though I'd think this will work, it's a little awkward. Setting the
format type in the query only changes the display, doesn't let me
query off of it. (i.e. format mm/dd/yyyy displays 01/01/2007 but I
can't use Left,2 and get "01" from that.)

Thanks!
Darrell
Are you storing text or numeric data that "represents" Date data or are
these actually DateTime types formatted differently. If the former, bad
idea. If the latter then the dates are already the same because formatting
doesn't affect how dates are stored.

If your actual question is "how do I display a date as MMYY then use a
format property of "mmyy" or use the format function...

=Format([DateField], "mmyy")

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Jan 5 '07 #2

Rick Brandt wrote:
ve***@aol.com wrote:
I'm thinking this is easy but can't get it. I have a table with
following:

Table1
Date 1/1/2007

Table2
Type 0107 (This is MMYY of above)

So I'm having trouble using a query to turn the date from Table 1 into
the Type from Table 2. I know when the dates are >=10, I can just use
Left,2 and Right, 2. I don't want to have to put a long condition
that says "If month <10, then use '0'&Left,1, else use Left,2"
Though I'd think this will work, it's a little awkward. Setting the
format type in the query only changes the display, doesn't let me
query off of it. (i.e. format mm/dd/yyyy displays 01/01/2007 but I
can't use Left,2 and get "01" from that.)

Thanks!
Darrell

Are you storing text or numeric data that "represents" Date data or are
these actually DateTime types formatted differently. If the former, bad
idea. If the latter then the dates are already the same because formatting
doesn't affect how dates are stored.

If your actual question is "how do I display a date as MMYY then use a
format property of "mmyy" or use the format function...

=Format([DateField], "mmyy")

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
The dates are coming in as dates. The other are text values. No my
question isn't what you describe. And now I actually want to add a
follow up.

Table 1
Name Effective Expiration
Bob 1/1/2006 9/30/2006

I have a table that shows all of the months "Bob" was effective. The
table looks like:

Bob 0106 (text)
Bob 0206
Bob 0306

So this is why I want to append the leading 0 to the month. My follow
up though is:

Previously to do the above, I had 9 queries which said:
1. If effective >=1/1/2006 and <=1/31/2006 then ="0106"
2. If effective >=2/1/2006 and <=2/28/2006 then ="0206", etc.

I have to cycle through 3 years and add a new query every time we move
to a different month. There must be an easier way to either cycle
through or set this up. The output is later used in another query. I
need unique values for the other query for each month and year person
is eligible.

Jan 5 '07 #3
ve***@aol.com wrote:
The dates are coming in as dates. The other are text values. No my
question isn't what you describe. And now I actually want to add a
follow up.

Table 1
Name Effective Expiration
Bob 1/1/2006 9/30/2006

I have a table that shows all of the months "Bob" was effective. The
table looks like:

Bob 0106 (text)
Bob 0206
Bob 0306

So this is why I want to append the leading 0 to the month. My follow
up though is:

Previously to do the above, I had 9 queries which said:
1. If effective >=1/1/2006 and <=1/31/2006 then ="0106"
2. If effective >=2/1/2006 and <=2/28/2006 then ="0206", etc.

I have to cycle through 3 years and add a new query every time we move
to a different month. There must be an easier way to either cycle
through or set this up. The output is later used in another query. I
need unique values for the other query for each month and year person
is eligible.
But, what is the purpose of the 9 queries? Are you importing the data with
the mmyy format into tables with real dates? Going in the other direction?
Are you trying to create a query that joins the two tables on the differing
date fields?

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com

Jan 5 '07 #4

Rick Brandt wrote:
ve***@aol.com wrote:
The dates are coming in as dates. The other are text values. No my
question isn't what you describe. And now I actually want to add a
follow up.

Table 1
Name Effective Expiration
Bob 1/1/2006 9/30/2006

I have a table that shows all of the months "Bob" was effective. The
table looks like:

Bob 0106 (text)
Bob 0206
Bob 0306

So this is why I want to append the leading 0 to the month. My follow
up though is:

Previously to do the above, I had 9 queries which said:
1. If effective >=1/1/2006 and <=1/31/2006 then ="0106"
2. If effective >=2/1/2006 and <=2/28/2006 then ="0206", etc.

I have to cycle through 3 years and add a new query every time we move
to a different month. There must be an easier way to either cycle
through or set this up. The output is later used in another query. I
need unique values for the other query for each month and year person
is eligible.

But, what is the purpose of the 9 queries? Are you importing the data with
the mmyy format into tables with real dates? Going in the other direction?
Are you trying to create a query that joins the two tables on the differing
date fields?

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Going in other direction. The values with dates are going into tables
with text fields "mmyy".

Jan 5 '07 #5
ve***@aol.com wrote:
>
Going in other direction. The values with dates are going into tables
with text fields "mmyy".
And you are doing this with an append query? If so you just use the Format
fucntion like I posted earlier. Instead of IIf() use...

Format(DateField, "mmyy")

That will return a string in the format 0107 for this month.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


Jan 5 '07 #6

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

Similar topics

15
by: Simon Brooke | last post by:
I'm investigating a bug a customer has reported in our database abstraction layer, and it's making me very unhappy. Brief summary: I have a database abstraction layer which is intended to...
5
by: Macca | last post by:
Hi, I have a table which has a date/time field. I am storing them as follows :- 01/01/2005 11:25 01/01/2005 19:44 02/01/2005 05:04
5
by: Tim Marsden | last post by:
Hello, I am building a parameterised query in vb.net for execution against a SQL server database. I am using a OLEDB command and OLEDB parameters. If one of the parameters is a date I sometimes...
20
by: andreas | last post by:
When I copy a vb.net project using date formats from one PC with a windows date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then I get errors. How can I change for a while in the...
2
by: syntego | last post by:
We commonly use triggers to log changes to our main tables to historical log tables. In the trigger, we create a concatenated string of the old values by casting them as follows: ...
17
by: Petyr David | last post by:
Just looking for the simplest. right now my perl script returns an error messge to the user if the date string is invalid. would like to do this before accessing the server. TX
2
by: Billy | last post by:
This string is supposed to provide all records from an MDB database that match the courier and date specified in the query. I Response.Write the query and I get a date as 1/27/2007. The date...
2
by: thewilldog | last post by:
Hello, I've reviewed the archives here to address the issue, but I'm still running into problems. I've got a table field populated with the record date in text "YYYYMMDD" To convert it into a...
1
by: Maciej07 | last post by:
Hello, We are using SQL server 2000 on W2k Server and MS Access 2000 ADP (like front-end). Now we try to change operating system for SQL Server 2000 from W2k to W2k3 and we found problem with...
15
by: cephal0n | last post by:
I have a technical Date problem that's really difficult for me, I have a "custom made" Date format MM.DD.YY this is actually extracted from SAP and theirs no other format option offered such as...
1
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...
0
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...
0
isladogs
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.