hi anyone please give me the dll code for converting date format mm/dd/yyyy into dd/mm/yyyy.
here iam using asp.net with vb.net...
hi it was very urgent please help me.....

Try this code. (It is from mscorlib.dll)

Dim outdt As Date = Date.Parse("12/31/2009")
        Console.WriteLine(outdt.ToString("dd-MM-yyyy"))

hi anyone please give me the dll code for converting date format mm/dd/yyyy into dd/mm/yyyy.
here iam using asp.net with vb.net...
hi it was very urgent please help me.....

Dim dateformat As New DateTimeFormatInfo()
        dateformat.ShortDatePattern = "MM/dd/yyyy"
        result = Date.Parse(dateString, dateformat)
Dim dateformat As New DateTimeFormatInfo()
        dateformat.ShortDatePattern = "MM/dd/yyyy"
        result = Date.Parse(dateString, dateformat)

hi iam using the following code it was not working,,,please rectify the errors.

Imports System
Imports Microsoft.VisualBasic

Namespace fillblank
    Public Class Class1
        Public Function covertdate(ByVal a As String)
            If a.Trim <> "" Then
                Dim b As Date = CDate(Date.Parse(a.ToString))
                b.ToString("dd-MM-yyyy")
            End If

            Return a
        End Function
    End Class
End Namespace

thank you.....

You should have to use Date.TryParseExact method.

Dim formats() As String = {"dd-MM-yy", "dd-MM-yyyy", "dd/MM/yyyy", "dd/MM/yyyy"}
 Dim dstr As String = "31-12-2009"
 Dim dt As Date

 Date.TryParseExact(dstr, formats, Nothing, Globalization.DateTimeStyles.None, dt)

You should have to use Date.TryParseExact method.

Dim formats() As String = {"dd-MM-yy", "dd-MM-yyyy", "dd/MM/yyyy", "dd/MM/yyyy"}
 Dim dstr As String = "31-12-2009"
 Dim dt As Date

 Date.TryParseExact(dstr, formats, Nothing, Globalization.DateTimeStyles.None, dt)

hi iam using ur code but not working.....please correct it.
my coding is given below....

Imports System
Imports Microsoft.VisualBasic

Namespace fillblank
    Public Class Class1
        Public Function covertdate(ByVal a As String)
           
            Dim formats() As String = {"dd/MM/yyyy"}
            Dim dstr As String = a.ToString
            Dim dt As Date
            Date.TryParseExact(dstr, formats, Nothing, Globalization.DateTimeStyles.None, dt)

           

            Return a
        End Function
    End Class
End Namespace

thank you.......

Imports System
Imports Microsoft.VisualBasic

Namespace fillblank
    Public Class Class1
        Public Function covertdate(ByVal a As String) as Date
           'You may add as many as date format which recognize input date

            Dim formats() As String = {"dd/MM/yyyy","dd-MM-yyyy","dd.MM.yyyy","dd/MM/yy","MM-dd-yy","MM-dd-yyyy","MM/dd/yyyy"}
            
            Dim dt As Date
            Date.TryParseExact(a, formats, Nothing, Globalization.DateTimeStyles.None, dt)
           Return dt
        End Function
    End Class
End Namespace

hi iam using ur code but not working.....please correct it.
my coding is given below....

Imports System
Imports Microsoft.VisualBasic

Namespace fillblank
    Public Class Class1
        Public Function covertdate(ByVal a As String)
           
            Dim formats() As String = {"dd/MM/yyyy"}
            Dim dstr As String = a.ToString
            Dim dt As Date
            Date.TryParseExact(dstr, formats, Nothing, Globalization.DateTimeStyles.None, dt)

           

            Return a
        End Function
    End Class
End Namespace

thank you.......

Try to add in your webconfig file

<system.web>
	  <globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-fr" uiCulture="en-fr"/>
Imports System
Imports Microsoft.VisualBasic

Namespace fillblank
    Public Class Class1
        Public Function covertdate(ByVal a As String) as Date
           'You may add as many as date format which recognize input date

            Dim formats() As String = {"dd/MM/yyyy","dd-MM-yyyy","dd.MM.yyyy","dd/MM/yy","MM-dd-yy","MM-dd-yyyy","MM/dd/yyyy"}
            
            Dim dt As Date
            Date.TryParseExact(a, formats, Nothing, Globalization.DateTimeStyles.None, dt)
           Return dt
        End Function
    End Class
End Namespace

hi by using this code gete error as"Unable to cast object of type 'System.DBNull' to type 'System.IFormatProvider"
how it can solve.............
tnnx....

Try to add in your webconfig file

<system.web>
	  <globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-fr" uiCulture="en-fr"/>

hi this was also not helpful........
please provide a code for dll file for cnverting textbox date format into "dd/MM/yyyy" by your knowledge.....
it was very urgent please help me........

Please read post #2.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.