Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.

Answered Date in Excel sheet

  • Saturday, April 14, 2012 2:22 PM
     
     

    Hai,

    I am sending some data from a datagridview to a Excel sheet.

    That works.

    But I have a problem with Date's  , in the datagridview is 05-12-2012

    When i put it in a new excelsheet it is  05-12-2012 00:00 

    I found something for changing the format of Date in a Excel cel


     With wSheet

    .Columns("H:H").NumberFormat = "dd/mm/yyyy"

    End With

    But this is what i see then  in Excel 05-12-yyyy   ?????  yyyy and not 2012

    .Columns("H:H").NumberFormat = "dd/mm"

    Then it works ???  05-12 

    But I need , 05-12-2012   What do I put after NumberFormat ????

    I want to do it by code and not in the Excel sheet 


    • Edited by KeesBlunder Saturday, April 14, 2012 2:22 PM
    •  

All Replies

  • Saturday, April 14, 2012 9:42 PM
     
     Answered

    Maybe this link is useful.   http://support.microsoft.com/kb/922069

    If you use "dd/mm/yyyy" for a format string, what should happen when you pass it this string, "05-12-2012"?  Aren't hose are different formats?

    Rudy   =8^D

      

    Mark the best replies as answers. "Fooling computers since 1971."

    http://thesharpercoder.blogspot.com/

    • Marked As Answer by KeesBlunder Sunday, April 15, 2012 11:41 AM
    •  
  • Sunday, April 15, 2012 11:41 AM
     
     

    Yep , 

    This is it , thanks for the link.


     .Columns("H:H").NumberFormat = "dd/mm/jjjj"