Re-format a date-string?

When I use this line with "Mail":
set theReceivedTime to date received of theMessage as date
I get this:
onsdag 11 februari 2009 19.24.16
I need this to be in standard datetime-format, like this:
2009-02-11 19:24:16
What is the easiest way to do this?
Are there any built in functions to handle this, or do I (usch :)) need to create this by my self?

Super!
Just one thing
This gives me this response:
2009-02-12 19:0:0
It should be ... 19:00:00.
It's striking out one "0" in the minute and second...
And I'm guessing that would happend 01:00:00 thru 09:00:00 as well.?
I tried to understand your code, but came out blanc

Similar Messages

  • How do I format a date string in ISO 8601 format?

    Post Author: Perth
    CA Forum: Formula
    I am using a SaaS application, and uploading Crystal XI report templates to run using the application's reporting page. My custom date fields are stored using the ISO date format, and are made available as text strings in the form "yyyy-mm-ddThh:mm:ss" eg. "2007-10-09T00:00:00". The SaaS vendor say use a Crystal function. I have tried CDATE, DATEVALUE etc but these don't recognise the format as a valid date. I want to display this date as dd mmm yyyy.  Any ideas?

    Post Author: Perth
    CA Forum: Formula
    I have found a solution from another forum and post it here to close this off.
    It requires defining a "Report custom function". Use the formula workshop to create a function, giving it a name. Then paste this:
    Function  (stringVar v1)Date (ToNumber (Left (v1,4 )),      ToNumber (Mid (v1, 6,2 )) ,      ToNumber (Mid (v1, 9,2 )) )
    I can now format this date in the normal way as it is a date!

  • Formatting a date string

    I thought this would be easy enough, but I am having so much trouble doing this.
    I have a time stamp constant, which I have adjusted so that it is in the following format:
    %m/%d/%y
    Since I can't save files with " / " character, I am goint to use " . " instead.
    My original plan was using a 'search and split string' using '/' as a divider.
    This would give me 3 strings:
    %m
    /%d
    /%y
    That is perfect, except I dont want the '/' in front of the %d and %y.
    Could someone help me out with this last step?
    Cory K

    Or... You could just use the Format Date/Time String function:
    Message Edited by smercurio_fc on 08-08-2008 01:43 PM
    Attachments:
    Example_VI.png ‏4 KB

  • Convert String to Date and Format the Date Expression in SSRS

    Hi,
    I have a parameter used to select a month and year  string that looks like:    jun-2013
    I can convert it to a date, but what I want to do is,  when a user selects a particular month-year  (let's say "jun-2013")
    I  populate one text box with the date the user selected , and (the challenge Im having is)  I want to populate a text box next to the first text box with the month-year  2 months ahead.    So if the user selects 
    jun-2013   textbox A will show  jun-2013 
    and textbox B will show  aug-2013..
    I have tried:
    =Format(Format(CDate(Parameters!month.Value  ),  
    "MM-YYYY"  )+ 2  )   -- But this gives an error
    This returns the month in number format   like "8"    for august...
    =Format(Format(CDate(Parameters!month.Value  ), 
    "MM"  )+ 2  )
    What is the proper syntax to give me the result    in this format =  "aug-2013"  ???
    Thanks in advance.
    MC
    M Collier

    You can convert a string that represents a date to a date object using the util.scand JavaScript method, and then format a date object to a string representation using the util.printd method. For more information, see:
    http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.1254.html
    http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.1251.html
    In your case, the code would be something like:
    var sDate = "2013-01-10";
    // Convert string to date
    var oDate = util.scand("yyyy-mm-dd", sDate);
    // Convert date to new string
    var sDate2 = util.printd("mm/dd/yyyy", oDate);
    // Set a field value
    getField("date2").value = sDate2;
    The exact code you'd use depends on where you place the script and where you're getting the original date string, but this should get you started.

  • DateTimeFormatter.format() and date stored as string

    Greetings,
    I need to display some data in a spark data grid and would like to format a date from that data with a labelFunction calling a DateTimeFormatter's format function.
    The date is stored in my ArrayCollection in the following format '2004-05-03 01:03:52.0'
    my formatter is as follows
    <s:DateTimeFormatter id="dateFormatter" dateTimePattern="YYYY-MM-DD" />
    I would like my label function to return something like
    return "Date: " + dateFormatter.format( item[column.dataField]); // where the item[column.dataField] = "2004-05-03 01:03:52.0"
    The date is coming up blank. I'm thinking I need to convert the string "2004-05-03 01:03:52.0" to a Date object first, then pass that into the format() call.
    Is that the way to go? If so, what's the best way to handle that?
    Thanks

    Thank you Sumesh, but the problem was with getting the string converted to a date. I found a solution on
    http://polygeek.com/4137_actionscript3_batbelttime-utilities
    * Convert an MySQL Timestamp to an Actionscript Date
    * Thanks to Pascal Brewing [email protected] for the beautiful simplicity.
    public static function convertMySQLTimeStampToASDate( time:String ):Date{
    var pattern:RegExp = /[: -]/g;
    time = time.replace( pattern, ',' );
    var timeArray:Array = time.split( ',' );
    var date:Date = new Date( timeArray[0], timeArray[1]-1, timeArray[2],
    timeArray[3], timeArray[4], timeArray[5] );
    return date as Date;
    I pass in my string and it gets converted to a Date. I then pass the Date to the DateTimeFormatter.format() and everything works as expected.
    Thanks

  • How do I convert an 8 bit serial data string I have received (say 01110101) into decimal format??

    I am having a hard time finding a function that will help me convert an 8 bit serial data string I have received (say 01110101) into decimal format.

    When you have your front panel displayed, you should a whole palette of controls that you can place on the front panel. If the palette is not displayed, thne just right click on your mouse and it should appear. The upper left most set of controls on the palette is Numeric. Go there and select Numeric Indicator to display a numeric output. On the diagram, you can also right click the output 1 and select Create>Indicator. The format string is %b (as in boy) for a binary string. As I said, this should be the value for the format string input. You can right click on the Scan From String and select Edit Scan String. This will bring up a dialog box in which you pick what you want to do (Scan Number) and how you want to do it (Scan Binary Integer
    It sounds like you really need to take a course in LabVIEW programming. There are are links here to NI classes and some on-line tutorials.

  • Formatting an XML string that has a date

    Hi All - new to this forum!
    Not familiar with XML operations and seeking some advise. I have a field that contains XML text that has a date within that I want to extract and format appropriately for some reports.
    Getting to the date portion of the field is not pretty (original code below) and could desire some work itself, but the real problem lies in formatting the date once extracted; sometimes the date text is in the format of "Month DD YYYY" and other times "DD Month YYYY" so the below code fails if the latter is found.
    SELECT TO_DATE(RTRIM(SUBSTR(email_variables, INSTR(email_variables,'CHECKIN_DATE')+22,18),']]></CHECKIN_DATE><CHECKOUT_DATE>]'),'Month DD YYYY') CHECKIN_DATE,COUNT(*)
    FROM t_ecomm_relations_queue
    WHERE code_corr_ecat = 'PREA'
    AND status IN ('A', 'R')
    AND TO_DATE(RTRIM(SUBSTR(email_variables, INSTR(email_variables,'CHECKIN_DATE')+22,18),']]></CHECKIN_DATE><CHECKOUT_DATE>]'), 'Month DD YYYY') < TRUNC(SYSDATE) + 7
    AND TO_DATE(RTRIM(SUBSTR(email_variables, INSTR(email_variables,'CHECKIN_DATE')+22,18),']]></CHECKIN_DATE><CHECKOUT_DATE>]'), 'Month DD YYYY') >= TRUNC(SYSDATE)
    GROUP BY TO_DATE(RTRIM(SUBSTR(email_variables, INSTR(email_variables,'CHECKIN_DATE')+22,18),']]></CHECKIN_DATE><CHECKOUT_DATE>]'),'Month DD YYYY');
    Any ideas for more efficient code or options for formatting is appreciated.
    Thank you!

    The best thing to do with a date you want to report on, is to not store it corrupted inside XML.
    Multiple reasons why are discussed here.
    If you are stuck with the ugly inefficient design, then you are probably stuck with ugly inefficient code as a result.

  • Need help in formatting the Date - Date does not

    Need help in formatting the Date - Date does not formats and give Not a valid month error in the below scenario.
    select oc.ST_PGM_MGR, r.ag_dnum, get_major_work_type(r.perf_eval_rtng_id) "v_work_code", r.ag_dnum_supp "supp", r.intfinal, to_char(r.formdate,'MM/DD/YYYY') "formdate", to_char(r.servfrom,'MM/DD/YYYY') "srv_from", to_char(r.servto,'MM/DD/YYYY') "srv_to", descript, add_months(to_char
    --- Bellow line of Code on trying to format it to mm/dd/yyyy gives the error
    (r.formdate, 'DD-MON-YYYY'),12) "formdate2"
    from  table REdited by: Lucy Discover on Jul 7, 2011 11:34 AM
    Edited by: Lucy Discover on Jul 7, 2011 1:05 PM

    Your syntax is wrong - look at the post above where this syntax is given:
    to_char (add_months(r.formdate,12), 'MM/DD/YYYY') "formdate2"Look at the formula from a logical perspective - "inside out" to read what is happening -
    take formdate, add 12 months
    add_months(r.formdate, 12)then apply the to_char format mask - basic syntax
    to_char(date, 'MM/DD/YYYY')Compare to your syntax:
    to_char(add_months(r.formdate, 'MM/DD/YYYY'),12) "formdate2"You will see your format string inside the call to add_months, and your 12 inside the call to to_char.
    Good luck!

  • Formatting a date in XSLT

    I am working with an XSLT fragment in dreamweaver and all
    seems to be working fine except when it comes to the date field in
    the XML it is transforming. It looks like dreamweaver has no
    options in it for formatting a date. Looking on the web it appears
    that XSLT doesn't have a function for that except if you are
    running XSLT 2.0??
    my XML looks like
    <pubDate>Wed, 04 Apr 2007 04:00:00
    +0100</pubDate>
    Can anyone help me just show only this part, "Wed, 04 Apr
    2007"
    thanks
    chris

    >I am working with an XSLT fragment in dreamweaver and all
    seems to be
    >working
    > fine except when it comes to the date field in the XML
    it is transforming.
    > It
    > looks like dreamweaver has no options in it for
    formatting a date. Looking
    > on
    > the web it appears that XSLT doesn't have a function for
    that except if
    > you are
    > running XSLT 2.0??
    Correct.
    > my XML looks like
    > <pubDate>Wed, 04 Apr 2007 04:00:00
    +0100</pubDate>
    > Can anyone help me just show only this part, "Wed, 04
    Apr 2007"
    With XSLT, this should work:
    <xsl:value-of select="substring(pubDate,1,16)"
    order="descending" />
    The substring function variables are:
    substring(node, postition of start character in string, total
    number of
    characters to include)
    It's akin to a TRIM string statement in server-side
    programming languages.
    -Darrel

  • ERROR [HY000] [DataDirect][ODBC Progress OpenEdge Wire Protocol driver][OPENEDGE]Invalid date string (7497) (pgoe1022.dll)

    I am selecting data from a Progress database using the Data Direct Open Edge 10.1.B driver. The target table stores the date values as varchar in this format "22-OCT-14" In the select statement I can use Progress statements or T-SQL to transform
    the varchar to a date - but cannot do the same in the WHERE clause 
    Select po_number, cast(po_date as date) as [po_date] from [po_table] 
    (no problem - the [po_date] field stored as "22-OCT-14" is returned as "2014-10-22 00:00:00"
    but when I include the cast in the where clause I get the error described in the title
    Select [po_number], [po_date] from [po_table WHERE cast([po_date] as date)<= '10/22/2014' - NO GOOD
    I have tried very many combinations of the date string format , different functions and sub-queries but cannot find an answer

    The sql strings I posted are working examples - I've tried the ISO format you included - any number of date formats will work when the target field is a "Date" field - but trying any kind of transform statment to processa date stored
    as a varchar in the WHERE CLAUSE throws the erro
    Storing dates in a varchar column is a bad idea on any platform. Apparently there are strings in that column which cannot be converted to dates.
    On SQL Server you could have found this with
    SELECT po_date FROM po_table WHERE isdate(po_date) = 1
    What you should use on Progress, I have no idea.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Formatting  a Date

    Hi, Can someone tell me how to simply format the date to this:
    MON DD, YYYY
    Thanks

    You can use the SimpleDateFormat like:
    java.text.DateFormat df = new java.text.SimpleDateFormat(format);where formar is a String like:
    format= "dd/MM/yyyy";for a date like "07/06/2003"
    You can use any format you want modifying the format using the following symbols:
    Symbol Meaning Presentation Example
    G era designator (Text) AD
    y year (Number) 1996
    M month in year (Text & Number) July & 07
    d day in month (Number) 10
    h hour in am/pm (1~12) (Number) 12
    H hour in day (0~23) (Number) 0
    m minute in hour (Number) 30
    s second in minute (Number) 55
    S millisecond (Number) 978
    E day in week (Text) Tuesday
    D day in year (Number) 189
    F day of week in month (Number) 2 (2nd Wed in July)
    w week in year (Number) 27
    W week in month (Number) 2
    a am/pm marker (Text) PM
    k hour in day (1~24) (Number) 24
    K hour in am/pm (0~11) (Number) 0
    z time zone (Text) Pacific Standard Time
    ' escape for text (Delimiter)
    '' single quote (Literal) '
    Juan Carlos

  • Formatting a date inside a colum tag

    Hi eveyone
    I am trying to format the column of a table so that the date will display in a certain format.
    The code that I use is doing nothing - apart from staring at me!!
    This is the snippet...
    <display:column property="departDate" sort="true"
             headerClass="sortable"
            paramId="departDate" paramProperty="departDate"
            title="Depart Date"
            class="departDate">
            <fmt:parseDate value="${departDate}" type="date" pattern="dd/mm/yyyy" var="parsed" />
            <fmt:formatDate value="${parsed}" type="date" dateStyle="full"/>       
        </display:column>Regards

    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import java.util.GregorianCalendar;
    public class DateFormatter {
         public static void main(String[] args) {
              Calendar calendar = new GregorianCalendar();
              double[] limits = {1, 2, 3, 4, 21, 22, 23, 24};
              String[] dateFormats = {"st", "nd", "rd", "th", "st", "nd", "rd", "th"};
              ChoiceFormat choiceFormat = new ChoiceFormat(limits, dateFormats);
              String dateFormat = "EEEEE dd''{0}'' MMMMM";
              MessageFormat messageFormat = new MessageFormat(dateFormat);
              messageFormat.setFormat(0, choiceFormat);
              Object[] msgArgs = {
                   new Integer(calendar.get(Calendar.DATE))
              String message = messageFormat.format(msgArgs);
              System.out.println(message);
              SimpleDateFormat date = new SimpleDateFormat(message);
              System.out.println(date.format(calendar.getTime()));
    }

  • Formatting a date according with user settings (user defaults)

    Hi All,
    I need to format a date I receive via JS in YYYYMMDD format according with user defaults <b>without</b> server side action (I know, this is not a good issue, but they want it).
    My solution is to write a JS function (there are a lot of it on WWW) which accepts two strings and formats the first according to the second, something like:
    userFormattedDate = formatDate('20060613','DD.MM.YYYY');
    paying attention to generate 'DD.MM.YYYY' string on server side, according to user settings.
    But if this isn't a weblog, where is the question? :-D
    The question is: is there a JS function (in DatePicker or dateNavigator BSP) provided by standard libraries which serves similar functionality?
    Does exist a JS public standard library?
    Thanks.
    Dany

    Hi Durairaj,
    Tags <% %> are for server side actions.
    The question is about obtaining the same effect, but client side.
    Thanks.
    Dany

  • Formatting a Date based on the user's Locale

    I'm having some trouble formatting a date based on the user's locale. I'm aware you can do something like this:
       public static String getAsString( Object dateObject, Locale locale ) {
          DateFormat dateFormat = DateFormat.getDateInstance( DateFormat.MEDIUM, locale );
          return dateFormat.format( dateObject );
    However, this is returning something like Jan 21, 2009. I need 01/21/2009. Of course, if this was the UK locale it'd have to be 21/01/2009. Any help would be appreciated.

    another issue I'm running into is that when I'm logged in as a users' locale which uses '-' instead of '/' (i.e. 21-01-2009), I get a parse error. Can anyone provide any input? Thanks.
        * Parse a Date
        * @param dateString
        * @param locale
        * @return parsed Date
       public static Object parseDate( String dateString, Locale locale ) {
          DateFormat dateFormat = DateFormat.getDateInstance( DateFormat.SHORT, locale );
          try {
             return dateFormat.parse( dateString );
          catch( Exception exception ) {
             throw new ExceptionUtl( UtlMessageHelper.getMessage( UtlMessageConstants.ERROR_FailedParseDateFromString, dateString ), exception );
        * Format the given value into a DateFormat
        * @param dateObject
        *           Object value to be formatted
        * @param locale
        *           Locale format to use
        * @return dateObject in SimpleDateFormat
       public static String formatDate( Object dateObject, Locale locale ) {
          DateFormat dateFormat = DateFormat.getDateInstance( DateFormat.SHORT, locale );
          if( dateFormat instanceof SimpleDateFormat ) {
             SimpleDateFormat simpleDateFormat = ( SimpleDateFormat )dateFormat;
             String pattern = simpleDateFormat.toPattern();
             if( !pattern.contains( "yyyy" ) ) {
                pattern = pattern.replace( "yy", "yyyy" );
             if( !pattern.contains( "dd" ) ) {
                pattern = pattern.replace( "d", "dd" );
             if( !pattern.contains( "MM" ) ) {
                pattern = pattern.replace( "M", "MM" );
             simpleDateFormat = new SimpleDateFormat( pattern );
             return simpleDateFormat.format( dateObject );
          return null;
       }

  • Formatting a date like: Friday 24th January

    Formatting a date like: Friday 24th January
    Is there any way using the Java API to get the 'th' or 'st' bits on the numbers.
    I can't see it in java.text.SimpleDateFormat
    Thanks.

    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import java.util.GregorianCalendar;
    public class DateFormatter {
         public static void main(String[] args) {
              Calendar calendar = new GregorianCalendar();
              double[] limits = {1, 2, 3, 4, 21, 22, 23, 24};
              String[] dateFormats = {"st", "nd", "rd", "th", "st", "nd", "rd", "th"};
              ChoiceFormat choiceFormat = new ChoiceFormat(limits, dateFormats);
              String dateFormat = "EEEEE dd''{0}'' MMMMM";
              MessageFormat messageFormat = new MessageFormat(dateFormat);
              messageFormat.setFormat(0, choiceFormat);
              Object[] msgArgs = {
                   new Integer(calendar.get(Calendar.DATE))
              String message = messageFormat.format(msgArgs);
              System.out.println(message);
              SimpleDateFormat date = new SimpleDateFormat(message);
              System.out.println(date.format(calendar.getTime()));
    }

Maybe you are looking for

  • How is the best way to make a curved line in keynote?

    I have the new version of keynote but using the "curved line" in 'shapes' is not easy to make a symmetrical curved line. Can you suggest other simple ways to accomplish this?

  • SDK 1.4.2: does the required JRE/Plugin undermine the use of applets?

    I have overcome the problems of running applets under SDK 1.4.2 by installing the required plugin. Now everything runs fine again, but I am left with one crucial question. For me it's no problem to download those 30+Mb, but how can I expect people vi

  • Binding String Variables Into BOR Methods

    I have a function module that prompts the user for, among other things, free form comments which are appended to an overall comment log.  The comments are exported out of the fm as a string variable.  The plan is to carry the string along in the work

  • Delivery address in PO item level

    Hi, in PO item level there is a tab "Delivery address". Under this tab there is a Field "Address" having data for eg. 22706. 1.Please tell me from where this "address" comes. where is the customization for this "address". 2.Delivery address, is it re

  • Song capacity of 60G IPod and 20G IPod

    I have a 60GB IPod with 517 songs now loaded (approx. 4 minutes per song) and have only 40.2GB still available. My wife has a 20GB IPod with the same songs and has only 3.1GB still available. It seems highly unlikely that my IPod can hold the adverti