date format

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • karmantu
    New Member
    • May 2009
    • 1

    #1

    date format

    hello
    how to get date format month, date year time i.e may, 23 2009 12: 34


    comma must be near month


    i have used convert ( varchar, date, 100) in sql
    but i got - may 25 2009 12: 34 pm
    please give solution as soon as possible
  • PRR
    Recognized Expert Contributor
    • Dec 2007
    • 750

    #2
    Try this
    Code:
    DateTime n = DateTime.Now;
    Console.WriteLine(n.ToString("dd yyyy hh:mm"));

    Comment

    • razmataz
      New Member
      • Jun 2009
      • 2

      #3
      Hi,
      Try this

      DateTime n = DateTime.Now;

      Response.Write( n.ToString("MMM ,dd yyy hh:mm tt"));

      Comment

      • shawpnendu
        New Member
        • Jun 2009
        • 3

        #4
        Within SQL Server you have to use the below format:
        CONVERT ( data_type [ ( length ) ] , expression [ , style ] )

        But keep in mind no style will return you expected result. So what you can do? You must make the query in below way:

        SELECT CONVERT(VARCHAR (3),GETDATE(),7 )+', '+RIGHT('0' + RTRIM(DAY(GETDA TE())),2)+' '+ CONVERT(VARCHAR ,Year(GETDATE() ))

        Here I didn't add the time portion. Add time portion use the above technique.

        Hope it will help you.

        REGARDS
        <link to blog removed>
        Last edited by Frinavale; Jun 2 '09, 04:29 PM. Reason: Removed signature link: not relevant to question (spam). Post was originally in all caps, I converted it to normal case.

        Comment

        Working...