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

SELECT: Can someone help? This is annoying me!

Folks,

I'm working on an ecommerce website that deals with credit card expiry
dates. The table has two columns for year and month. I currently have
a select that says:

(ExpiryDateYear<=$currentYear AND ExpiryDateMonth<=$currentMonth)

Meaning where the card Expiry Date Year column is this year, or older
than this year *AND* where the Expiry Date Month column is this month or
older than this month.

This looked like it worked until...

If I ask to list all cards that are due to expire before June 2005 - It
lists all cards from January until May, for all years up to, and
including 2005. It omits anything from July to December for all the
years that fit the criteria.

Why is this the case? I would have thought the AND would have ensured
this did not happen.

If there is some thing wrong with the syntax of my query, I'd appreciate
it if someone could help clean it up.

Alternativly, as a work around, I'm pretty sure I can perform a calc on
the columns and use that in my query... Thus, could I do something like

$yymm<=ExpiryDate where ExpiryDate=(ExpiryDateYear+2000)+ExpiryDateMonth.

Using PHP, I can make the left side of my equation in any format - its
the sql syntax that is failing me.

All help, via the newsgroup, would be greatly appreciated,

Thanks
randelld
Jul 20 '05 #1
3 1246
Randell D. wrote:
Folks,

I'm working on an ecommerce website that deals with credit card expiry
dates. The table has two columns for year and month. I currently have
a select that says:

(ExpiryDateYear<=$currentYear AND ExpiryDateMonth<=$currentMonth)

Meaning where the card Expiry Date Year column is this year, or older
than this year *AND* where the Expiry Date Month column is this month or
older than this month.

This looked like it worked until...

If I ask to list all cards that are due to expire before June 2005 - It
lists all cards from January until May, for all years up to, and
including 2005. It omits anything from July to December for all the
years that fit the criteria.

Why is this the case? I would have thought the AND would have ensured
this did not happen.

If there is some thing wrong with the syntax of my query, I'd appreciate
it if someone could help clean it up.

Alternativly, as a work around, I'm pretty sure I can perform a calc on
the columns and use that in my query... Thus, could I do something like

$yymm<=ExpiryDate where ExpiryDate=(ExpiryDateYear+2000)+ExpiryDateMonth.

Using PHP, I can make the left side of my equation in any format - its
the sql syntax that is failing me.

All help, via the newsgroup, would be greatly appreciated,

Thanks
randelld


Forget about it - I resolved it - I kept thinking of the expiry dates as
dates, but really, they are just numbers - I performed a calculation
similar to what I suggested as a workaround above (and more importantly,
got the calc right) and it works fine and dandy - However I'm still
curious as to why my original select didn't work.

cheers to all
randelld
Jul 20 '05 #2
it's because July is greater than the current month. The year doesn't
matter according to your original criteria. If the year and month are
just numbers, i would have combined them so June 2004 becomes 200406.
Then you might just have a criteria that says ExpiryYYYYMM <=
$currentYYYYMM.

Randell D. wrote:
Randell D. wrote:
Folks,

I'm working on an ecommerce website that deals with credit card expiry
dates. The table has two columns for year and month. I currently
have a select that says:

(ExpiryDateYear<=$currentYear AND ExpiryDateMonth<=$currentMonth)

Meaning where the card Expiry Date Year column is this year, or older
than this year *AND* where the Expiry Date Month column is this month
or older than this month.

This looked like it worked until...

If I ask to list all cards that are due to expire before June 2005 -
It lists all cards from January until May, for all years up to, and
including 2005. It omits anything from July to December for all the
years that fit the criteria.

Why is this the case? I would have thought the AND would have ensured
this did not happen.

If there is some thing wrong with the syntax of my query, I'd
appreciate it if someone could help clean it up.

Alternativly, as a work around, I'm pretty sure I can perform a calc
on the columns and use that in my query... Thus, could I do something
like

$yymm<=ExpiryDate where ExpiryDate=(ExpiryDateYear+2000)+ExpiryDateMonth.

Using PHP, I can make the left side of my equation in any format - its
the sql syntax that is failing me.

All help, via the newsgroup, would be greatly appreciated,

Thanks
randelld

Forget about it - I resolved it - I kept thinking of the expiry dates as
dates, but really, they are just numbers - I performed a calculation
similar to what I suggested as a workaround above (and more importantly,
got the calc right) and it works fine and dandy - However I'm still
curious as to why my original select didn't work.

cheers to all
randelld

Jul 20 '05 #3
okay you're that already (i didn't read properly) :)

David L wrote:
it's because July is greater than the current month. The year doesn't
matter according to your original criteria. If the year and month are
just numbers, i would have combined them so June 2004 becomes 200406.
Then you might just have a criteria that says ExpiryYYYYMM <=
$currentYYYYMM.

Randell D. wrote:
Randell D. wrote:
Folks,

I'm working on an ecommerce website that deals with credit card
expiry dates. The table has two columns for year and month. I
currently have a select that says:

(ExpiryDateYear<=$currentYear AND ExpiryDateMonth<=$currentMonth)

Meaning where the card Expiry Date Year column is this year, or older
than this year *AND* where the Expiry Date Month column is this month
or older than this month.

This looked like it worked until...

If I ask to list all cards that are due to expire before June 2005 -
It lists all cards from January until May, for all years up to, and
including 2005. It omits anything from July to December for all the
years that fit the criteria.

Why is this the case? I would have thought the AND would have ensured
this did not happen.

If there is some thing wrong with the syntax of my query, I'd
appreciate it if someone could help clean it up.

Alternativly, as a work around, I'm pretty sure I can perform a calc
on the columns and use that in my query... Thus, could I do something
like

$yymm<=ExpiryDate where
ExpiryDate=(ExpiryDateYear+2000)+ExpiryDateMonth.

Using PHP, I can make the left side of my equation in any format -
its the sql syntax that is failing me.

All help, via the newsgroup, would be greatly appreciated,

Thanks
randelld


Forget about it - I resolved it - I kept thinking of the expiry dates
as dates, but really, they are just numbers - I performed a
calculation similar to what I suggested as a workaround above (and
more importantly, got the calc right) and it works fine and dandy -
However I'm still curious as to why my original select didn't work.

cheers to all
randelld

Jul 20 '05 #4

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

Similar topics

14
by: Craig Hoskin | last post by:
Hi everyone Have a problem I would areally appreciate help with. I have 3 tables in a standard format for a Bookshop, eg Products Categories Categories_Products the latter allowing me to...
3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
2
by: Ini | last post by:
Hi, I have a recordset containing names of photographs and descriptions of these photo's. For exempla: Photo: car01.jpg Description: Red Corvette
2
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell...
6
by: Chris Fink | last post by:
Does anyone know it is possible to include a small image(.gif .jpeg) within a <SELECT><option> so that the user would see the option text as well as a little image(icon) in the option? I know this...
4
by: VK | last post by:
Hello, I have a dataset which has one datatable in it. The dt has over 3000 rows in it. Now I would like to get the rows where the StartDate is 15 Feb 2005, so I did the following: ...
7
by: Matt Jensen | last post by:
Howdy Fairly simple question I think, I presume the answer is no it can't be reused for 2 *SELECT* statements, but just hoping for clarification. Just asking in the interests of trying to minimise...
5
by: visu | last post by:
Hi this is a question asked in this group two years back.. No answer for this question till date. now i am in the same situation of the questioner.. to find a solution for this problem. Can any...
4
by: Patrick Nolan | last post by:
I am using javascript to manipulate optgroups in select elements. When the results are displayed in Firefox 2.0 there is an annoying blank line at the top of the multi-line select box. This...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.