Convert channel display format from time to numeric in a script

I am trying to convert the Display format of a channel that contains time values (mm/dd/yyyy hh:nn:ss.ffff) from Time to Numeric. I know I can do this in the properties section of the data portal but I would like to do it in a script. I want to be able to automatically convert it without having to manually do it each time I import new data. What syntax is needed for this? 
I've already tried the ChnPropSet (and ChnPropValSet) commands but it doesn't change the Display format after I run the script. Thanks for all your help. 
Solved!
Go to Solution.

Hi Steinmeister,
i've found a way. You can use the "ChnCalculate"-Function but you must store it to a new channel.
Dim oGrp, oChn
Dim sChn
'iterate over all channels
For Each oGrp In Data.Root.ChannelGroups
For Each oChn In oGrp.Channels
sChn = transformTimeChnToNum(oChn)
If (sChn <> "") Then
Call ChnCopy(oGrp.Name & "/" & sChn, oGrp.Name & "/" & oChn.Name)
Call ChnDel(oGrp.Name & "/" & sChn)
End If
Next
Next
'function for transforming the channel
Function transformTimeChnToNum(oChannel)
transformTimeChnToNum = ""
If (oChannel.DataType <> DataTypeChnDate) Then
Exit Function
End If
transformTimeChnToNum = oChannel.Name & "_num"
Call ChnCalculate("Ch(""" & oChannel.ChannelGroup.Name & "/" & transformTimeChnToNum & """)=Val(Ch(""" & oChannel.ChannelGroup.Name & "/" & oChannel.Name & """))")
End Function

Similar Messages

  • ICS 2.x: How do I change the hour display format from AM/PM to 24 hour mode in the JavaScript?

    How do I change the hour display format from the AM/PM mode to the 24 hour mode
    in the JavaScript?
    <P>
    To change the hour display format,<BR>
    <P>
    <OL>
    <LI>Open the <I>loadpoint</I>/CalendarServer/cal/uicust/en/main.html
    file.
    <P>
    <LI>Go to the "Misc." section.
    <P>
    <LI>Edit the following line:<BR>
    <P>
    i18n['def clock'] = '24';
    </OL>

    laugh
    how analog. 
    neat idea, but i need to see that part of the screen after login on a fairly regular basis, otherwise i might seriously do this.

  • It takes 11 hours to convert to flv format from Quicktime

    I edited a DV movie from camera using FCP and one hour final movie after adding all animations and effects in .mov format which was about 12 GB takes about 11 hours to be converted to flv format is this usual or I need to do some thing.
    My system configuration is
    Power PC G5
    3500 MB RAM
    1.1 TB hard disk.
    I used Marcromedia Flash Encoder
    OS Mac OS X 10.5.8
    is there some thing that can be done to shorten the time as the compressor of FCP wont submit batch.That is an error I am getting in it.
    http://support.apple.com/kb/TA47672?viewlocale=en_US
    and any of the solution suggested above does not seems to work.
    This post is not about compressor problem I had asked that on another thread
    http://discussions.apple.com/thread.jspa?threadID=2374397&tstart=0
    but it says to install an old OS which is not some thing logical I feel to be able to use compressor I wont be downgrading my OS.
    What I want to know is to be able to convert to flv from .mov format so much time is it a usual thing or some thing can be done to shorten it.

    That's what I meant. You just need a good compression codec.
    Can you help to identify or let me know a few codecs I will try.
    Is FLV the only resource you streaming server will use?
    Yes it has to be flv.The decision is not in my hands it will be a Linux Server so if you are aware of any better file format let me know.I can suggest.
    You can use hardware compression systems to go directly to several different >low grade codecs but I've never used them.
    I do not have any such hardware but anyways
    thanks for this suggestion.

  • Is there any function module to convert the date format

    Dear ABAPers,
    Is there any function module to convert the date format from dd.mm.yyyy to dd-mmm-yyyy.
           I want to convert the date format from dd.mm.yyy to dd.mmm.yyy Eg.from 10.03.2008 to 10-mar-2009.
    Thanks & Regards,
    Ashok.

    hi,
    create custom function module or copy the below code in the report ..and use it
    the out put for below is :----Convert a DATE field into a full format date eg. March 23, 2000
    FUNCTION Z_CONVERT_DATE_INTO_FULL_DATE.
    ""Local interface:
    *"       IMPORTING
    *"             VALUE(DATE) LIKE  SY-DATUM
    *"       EXPORTING
    *"             VALUE(FORMATTED_DATE)
    *"       EXCEPTIONS
    *"              INVALID_DATE
    TABLES: TTDTG.
    DATA: BEGIN OF T_DATE,
            YYYY(4) TYPE C,
            MM(2) TYPE C,
            DD(2) TYPE C,
          END OF T_DATE.
    DATA: DAY(3) TYPE N.
    DATA: VARNAME LIKE TTDTG-VARNAME.
    IF DATE IS INITIAL.
      CLEAR FORMATTED_DATE.
      EXIT.
    ENDIF.
    check document date format
    CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
      EXPORTING
        DATE = DATE
      EXCEPTIONS
        PLAUSIBILITY_CHECK_FAILED = 1.
    IF SY-SUBRC NE 0.
      RAISE INVALID_DATE.
    ENDIF.
    MOVE DATE TO T_DATE.
    CONCATENATE '%%SAPSCRIPT_MMM_' T_DATE-MM INTO VARNAME.
    SELECT SINGLE * FROM TTDTG WHERE SPRAS = 'EN' AND VARNAME = VARNAME.
    WRITE T_DATE-DD TO DAY.
    CONCATENATE DAY ',' INTO DAY.
    CONCATENATE TTDTG-VARVALUE DAY T_DATE-YYYY INTO FORMATTED_DATE
      SEPARATED BY SPACE.
    ENDFUNCTION.
    the output is :--Convert a DATE field into a full format date eg. March 23, 2000
    Regards,
    Prabhudas

  • Display format input for UserDatasource

    Hi, i'm creating new userdatasouce, i had link this UDS to edittext and wanted to set display format as time. Anyone know how to do this ?

    hi
    try this
                   oForm.DataSources.UserDataSources.Add("APLX_DADO", BoDataType.dt_DATE, 20);
                    oItem = oForm.Items.Add("A_EDAOD", BoFormItemTypes.it_EDIT);
                    oItem.Left = 120;
                    oItem.Top = 90;
                    oItem.Height = 15;
                    oItem.Width = 50;
                    oItem.ToPane = 1;
                    oItem.FromPane = 1;
                    oEdit = (EditText)oItem.Specific;
                    oEdit.DataBind.SetBound(true, "", "APLX_DADO");
    i hope it helps
    but if you need time f.e. 12:23 you should use  BoDataType.dt_SHORT_TEXT, 5
    and then parse it to dateTime structure
    regards
    Edited by: Michal Wieczorek on Mar 18, 2008 10:35 AM
    Edited by: Michal Wieczorek on Mar 18, 2008 10:35 AM

  • Change display Date format from 06.2011 to june 2011 in output of Query

    Hi All,
                Change display Date format from 06.2011 to june 2011 in output of Query  Execution. i used time charcteristics 0calmonth in query, output display is coming 06.2011, i want to display output in june 2011 format, anyone tell me how to convert this Date format.

    Hi Nandish,
    as tibollo said you just need to mark 0CALMONTH with text in RSD1.
    Kindly note that you don't need to do data load for this object.
    It will automatically derive by system.
    Just change the Info object 0CALMONTH in RSD1, Go to Master Data/text column and check mark on with text.
    Then activate it.
    Regards,
    Ashish

  • TimeValue - Formating a time channel

    How do I Format a date/time chanel to have only the Time listed HH:MMS.
    Right now I have a Time Chanel of 01/19/2013  07:23:12:0000 which I believe is the default format.  I want to create a seperate channel that would only have the Time in it.  I am also trying to Seperate out the Hr, Min, Sec into individual channels as well.

    Hi Jcheese,
    The date/time channel in DIAdem is always a numeric channel which counts the seconds since the year 0. The representation of date/time values in VIEW or REPORT can be changed by setting the format like “hh:nn:ss”.
    Here are the settings for a VIEW table:
    One possible way to seperate the time information is the following script:
    Dim oTChn, oHChn, oMChn, oSChn, iLoop
    set oTChn = Data.GetChannel("MyTimeChannel")
    set oHChn = Data.Root.ActiveChannelGroup.Channels.Add("MyHourC​hannel",DataTypeChnFloat64)
    set oMChn = Data.Root.ActiveChannelGroup.Channels.Add("MyMinut​eChannel",DataTypeChnFloat64)
    set oSChn = Data.Root.ActiveChannelGroup.Channels.Add("MySecon​dChannel",DataTypeChnFloat64)
    for iLoop = 1 to oTChn.Size
    oHChn(iLoop) = Hour(oTChn(iLoop))
    oMChn(iLoop) = Minute(oTChn(iLoop))
    oSChn(iLoop) = Second(oTChn(iLoop))
    next
    Greetings
    Walter

  • Display different types of file formats from contents server on web UI

    Hi,
    I have to read different types of documents from content server and display it in web page using webdynpro abap.
    Different types of documents are : Tif, Jpeg, BMP, PNG etc. need to be convert into gif format and display
    Txt files as it is.
    PDF files as it is.
    Microsoft office documents as it is.
    ALF files i.e. printlists to be shown on web page.
    Please anyone has any information regarding this let me know ASAP.
    Thanks & Regards,
    Manali

    hi ,
    pls refer the below thread :
    Dynamic Use of Mime in component
    n check wid thomas reply in the thread :
    Create the cached response object that we will insert the  content
    Well you can manipulate the MIME content at runtime by using the API: CL_MIME_REPOSITORY_API. However if your content is temporary, it is more efficient to just place the content directly into the ICM cache. You don't have the overhead of having to both write and then delete it from the database. Here is an example of how you can do this:
    I hope it wud be helpful
    rgds,
    amit

  • Day of year bug - format date/time string and scan from string?

    I've noticed that the day of year returned by "Format Date/Time String.vi" starts with a value of 1 for Jan-1 while "Scan from String.vi" wants a 0 index.  Is this a bug or feature?  
    (I'm using Labview 2010 Service Pack 1)

    I think the best idea is to use seconds since for your arithmetic, because it is going to be the most consistent and robust solution. Knowing that a day has 86400 seconds is all that is needed and you won't run in possible inconsistencies with date time implementations caused by our anything but logic calender. I would hazard that the functionality of converting a timestamp into year and day of year and back is impossible to make consistent without sacrificing other possibly conflicting transformation in the Timestamp into String and Timestamp from String manipulations.
    "Seconds since" being the actual base unit in all LabVIEW timestamps, it is best to do any arithmetic on it in this base unit.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How can i format my MacBook Pro hard disk and recover my data from time capsule?

    Hello,
    My MacBook Pro is running slow, more and more. Everything started with the "upgrade" to Lion.
    Can I re-format my hard disk and recover from Time Capsule only the data and applications I really need (including Snow Leopard as OS, maybe)?
    Thanks

    The problem is that it is a Western Digital 3.5 inch internal hard drive housed inside a hard drive caddy. So the only way to connect it to my computer is through a dock.

  • TS4163 Every time I try to export my movie into a Windows Format from compressor it shrinks the movie to 27 seconds.WHY? HELP

    Every time I try to export my movie into a Windows Format from compressor it shrinks the movie to 27 seconds.WHY? HELP

    Probably because you have the free version of Flip4MAc from Telestream that limits exported files to 30 seconds or so. There ae several paid versions  – depending on your requirements
    Good luck.
    Russ

  • HT1553 I restored my hard drive from time machine. Why is iPhoto not displaying images properly?

    I restored my hard drive from time machine after power blinks corrupted the file system so badly that disk utility could not repair it. Since then, iPhoto has not displayed images correctly. Events are there, and blank squares are shown, but that's all. I rebuilt small and all thumbnails and permissions -- I think the top three or four options in the iPhoto rebuild utility, which took five hours to do but which seems not to have changed anything. The iPhoto library is still more than 100GB, so the photos are there. I didn't choose rebuild from backed up --- whatever the final option on the rebuild menu offers -- because that seems to be appropriate only when a backup is interrupted. Could certainly do it, though. How do I get iphoto behaving again? I have full time machine backups saved automatically and another fairly recent copy on a separate hard drive stored remotely. Thanks for whatever help anyone can provide. I've looked at existing questions and solutions without success so far.

    What version of iPhoto and system are your running?  Since you've tried rebuilding with iPhoto give this a try:
    Using iPhoto Library Manager  to Rebuild Your iPhoto Library
    Download iPhoto Library Manager and launch.
    Click on the Add Library button, navigate to your Home/Pictures folder and select your iPhoto Library folder.
    Now that the library is listed in the left hand pane of iPLM, click on your library and go to the File ➙ Rebuild Library menu option
    In the next  window name the new library and select the location you want it to be placed.
    Click on the Create button.
    Note: This creates a new library based on the LIbraryData.xml file in the library and will recover Events, Albums, keywords, titles and comments. However, books, calendars, cards and slideshows will be lost. The original library will be left untouched for further attempts at fixing the problem or in case the rebuilt library is not satisfactory.
    If you have an external HD you might want to have the rebuilt copy created on it unless you have well more than 100 GB available on your boot drive.
    OT

  • Hi icant sync my photos from itunes to iphone ..it shows copying 1 out of something but afterwards it stops and no photos in iphone ..i formatted several times ..and from my utunes i have sync my brothers iphone it synced prefectly only its problm of my p

    hi icant sync my photos from itunes to iphone ..it shows copying 1 out of something but afterwards it stops and no photos in iphone ..i formatted several times ..and from my utunes i have sync my brothers iphone it synced prefectly only its problm of my iphone .......i have also deleted the ipod photo cache but still the same

    can any 1 help me

  • Function module to convert date format from yyyymmdd to mmddyyyy format

    function module to convert date format from yyyymmdd to mmddyyyy format

    Hi Rajitha,
    Do like this
    Data: Var1 type sy-datum,
             var2(8) type c.
    var1 = sy-datum.
    Concatanate var1+4(2) var1+6(2) var1+0(4) into var2.
    write var2.
    Reward Points if this helps,
    Satish

  • Sub-Menus are displaying away from their parent Menu for first time.

    Hi All,
    I have a problem with sub-menus display location. In my application, I have a JPopupMenu to which several sub-menus (*JMenu*) are added. All the JMenuItems inside JMenu are having an Icon (Image) along with menu item title. I am providing a facility to change the font size of Menu Item names as well as the ImageIcon size dynamically through a dialog box. When the size is changed to larger value than the existing, the menus as well as submenus are getting displayed correctly. But when I change the size of ImageIcon and the font to smaller value than the existing one, then the submenus are getting displayed away from their parent menu for the first time. The location of sub menu display is matching with the location when their size was larger. This problem appears only for the first display of sub menus after their sizes are changed. For the successive display, the locating is resetting automatically to correct location.
    So can anybody help me out about how to display submenus at correct location irrespective of font and image size changes for the first time also? Is there any event which gets fired when we change the font size or ImageIcon sizes? Is there any specific method to refresh the menu sizes if any of such properties (such as font size, ImageIcon size) are changed?
    If you need any additional information, feel free to ask.

    Below is the sample code for the query I placed. Steps to reproduce the problem are:
    1. Click on "Increase Font" button.
    2. Generate the popup at the right side corner of the screen (using right mouse click) such that the sub menu of edit should appear at left side of "Edit" option.
    3. Click on "Decrease Font" button.
    4. Generate the popup at the right side corner of the screen (using right mouse click) such that the sub menu of edit should appear at left side of "Edit" option.
    You will see that sub menu of edit menu is displayed away from the popup for the first time. The sub menu location matches with previous location when its font size was larger. Location resets automatically for the next successive displays.
    import java.awt.BorderLayout;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuItem;
    import javax.swing.JPanel;
    import javax.swing.JPopupMenu;
    public class JPopupDemo implements ActionListener {
      public static Font newFont=new Font("Times New Roman", Font.BOLD,24);
      JFrame frame = null;
      JPopupMenu popupMenu = null;
      JMenuItem fileMenu = null;
      JMenu editMenu = null;
      JMenuItem cutMenuItem = null;
      JMenuItem copyMenuItem = null;
      JMenuItem pasteMenuItem = null;
      JMenuItem findMenuItem = null;
        JPopupDemo(){
        frame = new JFrame("Popup Example");     
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        popupMenu = new JPopupMenu();
        fileMenu = new JMenuItem("File");
        editMenu = new JMenu("Edit");
        cutMenuItem = new JMenuItem("Cut");
        editMenu.add(cutMenuItem);
        copyMenuItem = new JMenuItem("Copy");
        editMenu.add(copyMenuItem);
        pasteMenuItem = new JMenuItem("Paste");
        pasteMenuItem.setEnabled(false);
        editMenu.add(pasteMenuItem);
        editMenu.addSeparator();
        findMenuItem = new JMenuItem("Find");
        editMenu.add(findMenuItem);
        popupMenu.add(fileMenu);
        popupMenu.add(editMenu);
        MouseListener mouseListener = new JPopupMenuShower(popupMenu);
        frame.addMouseListener(mouseListener);
        //frame.setSize(350, 250);
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Dimension dim = toolkit.getScreenSize();
        frame.setSize(dim.width,dim.height-100);
        JButton incrButton = new JButton("Increase Size");
        incrButton.setActionCommand("IncreaseSize");
        incrButton.addActionListener(this);
        JButton decrButton = new JButton("Decrease Size");
        decrButton.setActionCommand("DecreaseSize");
        decrButton.addActionListener(this);
        Container cp = frame.getContentPane();
        cp.setLayout(new BorderLayout());
        JPanel jp = new JPanel();
        jp.add(incrButton);
        jp.add(decrButton);
        cp.add(jp,BorderLayout.SOUTH);
        frame.setVisible(true);
    public static void main(String args[]) {
         JPopupDemo demo = new JPopupDemo();
      public void actionPerformed(ActionEvent ae)
            if (ae.getActionCommand().equals("IncreaseSize"))
                   newFont = new Font("Times New Roman", Font.BOLD,48);
                   setNewFont();
              else if (ae.getActionCommand().equals("DecreaseSize"))
                   newFont = new Font("Times New Roman", Font.BOLD,12);
                   setNewFont();
       public void setNewFont()
            popupMenu.setFont(newFont);
            fileMenu.setFont(newFont);
            editMenu.setFont(newFont);
            cutMenuItem.setFont(newFont);
            copyMenuItem.setFont(newFont);
            pasteMenuItem.setFont(newFont);
            findMenuItem.setFont(newFont);
    class JPopupMenuShower extends MouseAdapter {
      private JPopupMenu popup;
      public JPopupMenuShower(JPopupMenu popup) {
        this.popup = popup;
      private void showIfPopupTrigger(MouseEvent mouseEvent) {
        if (popup.isPopupTrigger(mouseEvent)) {
          popup.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent
              .getY());
      public void mousePressed(MouseEvent mouseEvent) {
        showIfPopupTrigger(mouseEvent);
      public void mouseReleased(MouseEvent mouseEvent) {
        showIfPopupTrigger(mouseEvent);
    }Edited by: VPKVL on Aug 4, 2008 1:18 AM

Maybe you are looking for