[thelist] Issues working with dates

Todd Richards todd at promisingsites.com
Fri May 8 12:45:13 CDT 2009


OK, I changed the format in the date picker so that it's yyyy/mm/dd and that
solved the sorting order.

Now I'm trying to not show the expired events.  I'm calling the date(), then
formatting it so that it's yyy/mm/dd format (which is set to the variable
"eventDate").  That part works.  I'm trying to pull a query from the DB
"where event_End_Date >= eventDate", and I get all of the dates.  If I do
event_End_Date <= eventDate", then I get no dates (as I shouldn't).  I'm
testing it right now with one event with an end date of 7/9/2008, and
another with 3/12/2009.

Todd



-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Todd Richards
Sent: Friday, May 08, 2009 7:44 AM
To: 'Ken Schaefer'; thelist at lists.evolt.org
Subject: Re: [thelist] Issues working with dates

Hi Ken -

I was using that "order by", they were DateTime fields, but the dates were
entered as mm-dd-yyyy.  I think that's the problem.

Todd


-----Original Message-----
From: Ken Schaefer [mailto:Ken at adOpenStatic.com] 
Sent: Thursday, May 07, 2009 11:33 PM
To: todd at promisingsites.com; thelist at lists.evolt.org
Subject: RE: [thelist] Issues working with dates

ORDER BY <yourDateTimeField>

is all you need assuming:
a) it is a DateTime field (check this again!)
b) the dates/times are being entered properly. If you are using Classic ASP
then you have no strong variable typing, so I'd ensure you format them as
yyyy-mm-dd when supplying parameters to your ADO Command object, to ensure
there is no ambiguity when sending them to SQL Server.

Cheers
Ken

________________________________________
From: thelist-bounces at lists.evolt.org [thelist-bounces at lists.evolt.org] On
Behalf Of Todd Richards [todd at promisingsites.com]
Sent: Friday, 8 May 2009 5:05 AM
To: thelist at lists.evolt.org; Joel at BizBa6.com
Subject: Re: [thelist] Issues working with dates

Hi Joel -

The dates are stored in a MS SQL database.  The dev server is running MS SQL
2000 and the production server was just upgraded to 2008 (big difference,
huh?)  :)

They are stored in a datetime field.  I was simply doing an "order by
endDate", but I guess that's probably not the best way to do it?

Todd





-----Original Message-----
From: Joel D Canfield [mailto:Joel at BizBa6.com]
Sent: Thursday, May 07, 2009 11:50 AM
To: todd at promisingsites.com; thelist at lists.evolt.org
Subject: RE: [thelist] Issues working with dates

> around with a dateDiff(), comparing the addedOn date with the current
> date,
> but that doesn't seem to be working.

what specific problem are you having?

> - Is it possible to do it the way I'm thinking (using the dateDiff
with
> the
> AddedOn field?  Should I be using a value "date()" rather than "now()"
> when
> entering the records, if I'm looking to compare the values?

if you'll never use the time, yeah, just use the date

> - Should I add another field in there for them to set a date to keep
it
> "featured"?

if you need one date field for "when it was added" and another for
"shelf life, sell by date" or whatever, yeah, two fields, if they're not
linked by some calculable number

> ISSUE 2:
> I'm listing upcoming events on an events page.  I'm trying to do
simple
> "order by endDate" (in format of mm-dd-yyyy).  I thought it was
working
> but
> last night I changed a date and now it's broke.  It seems that it's
> ordering
> by the "mm" part.  So if I have two dates, "05-11-2009" and
"11-10-2009",
> they are in the correct order.  But if I have  two events with dates
of
> "04-05-2022" and "10-22-2009", the one in 2022 comes first.

are your dates in a database, I'm assuming? which one? how is it storing
the dates, as a datetime field, or as strings? how are you doing the
comparison or sorting?

joel



--

* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester
and archives of thelist go to: http://lists.evolt.org
Workers of the Web, evolt !


-- 

* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester 
and archives of thelist go to: http://lists.evolt.org 
Workers of the Web, evolt ! 





More information about the thelist mailing list