Results 1 to 5 of 5

Thread: How to convert Date and Time Formats in VB.Net

  1. #1
    Join Date
    Feb 2009
    Posts
    90

    How to convert Date and Time Formats in VB.Net

    Hi,

    It used to work in vb6. I don't know the syntax in vb.net.

    current date and time....
    format (cstr(date),"DDMMYY")
    format(cstr(time),"HHMM")

    In my development code I use the following format to insert the date and time,check whether is it right and want any kind of changes.
    Dim date As DateTime = DateTime.Parse("August 10, 1980 10:10:23 AM")

    date.ToString("ddMMyy")
    date.ToString("hhmm")

    Thanks

  2. #2
    Join Date
    Mar 2008
    Posts
    258

    Re: How to convert Date and Time Formats in VB.Net

    A particular custom date and time format specifier produces an identical string representation regardless of whether it is used with a DateTime value or a DateTimeOffset value.

    Represents the day of the month as a number from 1 through 31. A single-digit day is formatted without a leading zero. For more information about using a single custom format specifier.
    The following example includes the d custom format specifier in several format strings.

    Code:
    Dim date1 As Date = #08/29/2008 7:27:15PM#
    
    Console.WriteLine(date1.ToString("d, M", _
                      CultureInfo.InvariantCulture)) 
    ' Displays 29, 8
    
    Console.WriteLine(date1.ToString("d MMMM", _
                      CultureInfo.CreateSpecificCulture("en-US")))
    ' Displays 29 August
    Console.WriteLine(date1.ToString("d MMMM", _
                      CultureInfo.CreateSpecificCulture("es-MX")))
    ' Displays 29 agosto

  3. #3
    Join Date
    Jan 2009
    Posts
    48

    Re: How to convert Date and Time Formats in VB.Net

    A standard DateTime format string consists of a single standard DateTime format specifier character that represents a custom DateTime format stringCustom DateTime Format Strings. The format string ultimately defines the text representation of a DateTime object that is produced by a formatting operation. Note that any DateTime format string that contains more than one alphabetic character, including white space, is interpreted as a custom DateTime format string.

    you can have more information from here:.NET Framework Developer's Guide

  4. #4
    Join Date
    Jan 2009
    Posts
    134

    Re: How to convert Date and Time Formats in VB.Net

    Represents the full name of the month as defined in the current DateTimeFormatInfo..::.MonthNames property. The following example includes the MMMM custom format specifier in a custom format string.

    Visual Basic
    Code:
    Dim date1 As Date = #08/29/2008 7:27:15PM#
    
    Console.WriteLine(date1.ToString("dddd dd MMMM", _
                      CultureInfo.CreateSpecificCulture("en-US")))
    ' Displays Friday 29 August

    C#
    Code:
    DateTime date1 = new DateTime(2008, 8, 29, 19, 27, 15);
    
    Console.WriteLine(date1.ToString("dddd dd MMMM", 
                      CultureInfo.CreateSpecificCulture("en-US")));
    // Displays Friday 29 August

  5. #5
    Join Date
    Jul 2010
    Posts
    1

    ThumbsUp Re: How to convert Date and Time Formats in VB.Net

    Dear Sachit ,

    your my hero .
    After daysssss looking for a solution for my problems about this datetime problem.....your post give me the correct solution.

    Thank you....muaahhhh

    Riris

Similar Threads

  1. How to convert UTC timestamp value to date and time
    By AsceTic! in forum MS Office Support
    Replies: 2
    Last Post: 02-02-2012, 07:14 PM
  2. Replies: 2
    Last Post: 29-11-2011, 09:29 AM
  3. Not able to convert image formats
    By Flacos in forum Windows Software
    Replies: 3
    Last Post: 26-11-2009, 03:51 PM
  4. Download DoPDF to Convert Any Documents to PDF Formats
    By taher in forum Windows Software
    Replies: 1
    Last Post: 30-03-2009, 08:55 AM
  5. HandBrake 0.9.3 now convert all formats
    By Mac rumor in forum Windows Software
    Replies: 0
    Last Post: 25-11-2008, 12:02 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,715,336,140.14204 seconds with 17 queries