Date Format

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
richh
Posts: 41
Joined: Tue Jan 25, 2011 8:48 pm

Date Format

Post by richh » Mon Jan 31, 2011 4:35 am

I noticed that rev formats short date as 1/30/11 and I am looking to convert it to a SQL datetime format.

I took a look at the dictionary under dateformat and I see the values I want to use such : %Y-%m-%d but I have not bee successful and put the date format in this manner.

I came up with the below, but I feel its sort of the long winded approach.

Code: Select all

   put the label of button "selectFromDate" into fDate
   
   convert fDate to dateItems
   put (the item 1 of fDate) & "-" & (the item 2 of fDate) & "-" & (the item 3 of fDate) into fSQLDateFormat
is there away in which I can take advantage of using dateformat in the way I initially wanted to use it?
- Rich

LiveCode 4.6.4
Dell Latitude E6400 running Windows XP SP3 / Mac Pro, Macbook Pro & Mac Mini running OS X 10.6.4

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: Date Format

Post by BvG » Mon Jan 31, 2011 7:34 am

There's no way to convert directly to your sql-demanded format. other approaches are similar long winded, for example:

Code: Select all

set the itemdelimiter to slash
put item 3 of theDate & "-" & item 1 of theDate & "-" & item 2 of theDate into theDate
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: Date Format

Post by bangkok » Mon Jan 31, 2011 1:55 pm

Sarah has some nice functions, "ready to use".

Check :

http://www.troz.net/rev/stacks/DateTime.rev

richh
Posts: 41
Joined: Tue Jan 25, 2011 8:48 pm

Re: Date Format

Post by richh » Mon Jan 31, 2011 5:19 pm

Thanks BvG & bangkok...

looks like I what I came up with I will use; however, I will definitely take a look at the Stack from Sarah.
- Rich

LiveCode 4.6.4
Dell Latitude E6400 running Windows XP SP3 / Mac Pro, Macbook Pro & Mac Mini running OS X 10.6.4

Post Reply