Jump to content

date query help


fullyscintilla

Recommended Posts

hi

 

I need a bit of help.. i'm working on search app written in php and it all but working aside one setback.

I seem to be having trouble properly searching for dates in the database. I have a form setup to allow the search between two dates.

 

My SQL query:

 

SELECT * FROM ".$table_name." WHERE enrollment_date>='2008-1-1' AND  enrollment_date<='2009-12-31'

 

But I seem to be getting mixed results..

 

is there a better way to search a db for dates?

 

~Thanx

Link to comment
Share on other sites

this isnt a syntax problem as it works.

 

Maybe mixed results isn't the right term.. the results aren't really mixed. its the same result each time.

the problem is it seems to be skipping dates or for some reason excluding them.

 

Say for instance in a db of 10 it's only returning 8 results. Even tho all the dates are between the dates searched. I cant figure out why its happening. I can switch to a single date query and locate each result. Its just the range query.

Link to comment
Share on other sites

It should be in some DATE format. You suggest you change it. I'm not sure how your other app handles it, but it's definitely is not a good set up.

 

I'm not sure what you mean here. The data itself is already in a "date" format of yyyy-mm-dd.

The data "type" for the column in the DB wasn't set to DATE. I've changed that now.

 

I was just wondering if anyone knew of a way to not have to use Leading zeros.

 

2008-03-23 < leading zeros

2008-3-23 < no leading zeros

 

@fenway:

maybe you could elaborate on that a bit for me? There are no leading zeros in a date?

Link to comment
Share on other sites

  • 2 months later...

Ok so "technically" you didn't spell it wrong because its in the dictionary as a "Slang" way to spell zero as plural. But the proper way is still "zeros".

 

I looked up zerofill and it comes up with absolutley nothing. Besides referring to a slang term for a low level format on a hdd. So obviously that term isn't even related to this questioning.

 

YES "leading" does make it sound optional.. Cuz the data I was given the leading zero was not given.

 

I was trying to find out a way I could make it work you guys decided to be smartbutts and instead of really helping me your just laughing at the fact that you think i'm retarded. When in reality I am not.

 

So thanks for that.

 

That was a full sentence, but not a full thought.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.