Consulting

Results 1 to 6 of 6

Thread: Date format,crosstab in SQL statement

  1. #1

    Date format,crosstab in SQL statement

    Hi, everyone

    [VBA]strSQL = "SELECT A,B,C " & _
    "WHERE(A)LIKE'" & a & "%'" & _
    "AND (C.TIME_STAMP)BETWEEN to_date('" & b & "','dd/mm/yyyy hh:MI:ss') AND to_date('" & b1 & "','dd/mm/yyyy hh:MI:ss')+1 " & _
    "GROUP BY A,B,C " [/VBA]

    I have such SQL statements in my excel vba. I succeed to retrieve the data and show the date. Bt it suppose to show date with time like 16/4/2013 7:05:34, bt it shows only 16/4/2013. When double click on the cell, then it will show the time and the above tab also will show include time when you double click.

    How to I show it straight away on the cell without I double click it?
    2. I have searched on google that "Transform and Pivot" are only use in Ms Access, it wouldn't work with Ms Excel. So instead of using that, which way can I use to retrieve data according to few columns?

    Thanks everyone.

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Set the NumberFormat for the date columns.

    Select the column, right click, format cells, number.

    Then enter: d/m/yyyy h:mm:ss

  3. #3
    Thank DRJ.
    But why it wil show together with the I? I chose dd/mm/yyyy hh:Mi:ss
    Attached Images Attached Images

  4. #4
    VBAX Tutor mohanvijay's Avatar
    Joined
    Aug 2010
    Location
    MADURAI
    Posts
    268
    Location
    try this
    [vba]

    Range("your range").NumberFormat = "dd/mm/yyyy hh:mm:ss"

    [/vba]

  5. #5

  6. #6
    Thanks mohanvijay. I got it.

    Sassora, I did look on that link before I post, and I tried it I still cant get what I want so I decide to ask here. thanks. once I solved it I will mark as solved. Thanks for remind.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •