Page 1 of 1

Date Format

Posted: Mon Jan 31, 2011 4:35 am
by richh
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?

Re: Date Format

Posted: Mon Jan 31, 2011 7:34 am
by BvG
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

Re: Date Format

Posted: Mon Jan 31, 2011 1:55 pm
by bangkok
Sarah has some nice functions, "ready to use".

Check :

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

Re: Date Format

Posted: Mon Jan 31, 2011 5:19 pm
by richh
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.