SQL Date Formatting

Pete pete at mollysrevenge.com
Fri Jan 13 12:46:11 EST 2012


Thanks Kay and Ken for some great ideas and warnings on this whole date
issue.  Ken, thanks for the date conversion script you sent me a few months
back, very useful.

I saw a headline somewhere recently that there's a move afoot to start
using a new calendar!  Apparently every month will have 28 days so there'll
be 13 of them and an extra day that's not part of any month at the end of
the year... or the beginning of the year... or in between the years...

Pete

On Fri, Jan 13, 2012 at 9:07 AM, Ken Ray <kray at sonsothunder.com> wrote:

> > 3) I love the fact I don't have to take into account if a user is using
> > mm/dd/yy format or dd-mm-yy format, once it converted to dateItems it's
> the
> > same on EVERY system.
>
> Just a little 'gotcha' here - I've been doing A LOT with dates and times
> recently, and discovered that you either need to make sure the
> 'useSystemDate' is set to true in your code, OR make sure to add the
> "system" keyword in any format conversion, otherwise it assumes
> US-formatted dates (this is documented in Bug #9893 in Bugzilla). Here's an
> example:
>
> If you're in the UK, and it's June 1, 2011, and you don't have
> "useSystemDate" active, if you:
>
>        put the short date
>        --> 6/1/11   (US-formatted)
>
>        put the short system date
>        --> 01/06/2011    (UK-formatted)
>
> If you do this:
>
>        put the short system date into tDate
>        convert tDate to dateItems
>
> you get this:
>
>        2011,1,6,0,0,0,5
>
> Which makes it *look* like it's reversing the month and day positions, but
> what's actually happening is the convert command hasn't been *told* that
> you're using a "system" date, so it attempts to convert "01/06/2011" as if
> it was a US date and ends up the way you see it here. To solve the problem
> you'd need to:
>
>        put the short system date into tDate
>        convert tDate from short system date to dateItems  -- you can also
> do "system date" instead of "short system date"
>        --> 2011,6,1,0,0,0,5
>
> So it's very important when dealing with non-US dates that you turn
> "useSystemDate" on OR use the "system" keyword otherwise you'll end up with
> a lot of headaches…
>
>
> Ken Ray
> Sons of Thunder Software, Inc.
> Email: kray at sonsothunder.com
> Web Site: http://www.sonsothunder.com/
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>


-- 
Pete
Molly's Revenge <http://www.mollysrevenge.com>



More information about the use-livecode mailing list