0

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.....

4
Contributors
10
Replies
11
Views
7 Years
Discussion Span
Last Post by __avd
0

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

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

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)
0
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.....

Edited by kanuri1: n/a

0

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)
0

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.......

0
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

Edited by __avd: n/a

0

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"/>
0
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....

0

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........

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.