[thelist] Issues working with dates

Ken Schaefer Ken at adOpenStatic.com
Thu May 7 23:32:35 CDT 2009


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 !


More information about the thelist mailing list