Click here to Skip to main content
16,020,840 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I want to ask you I am using a field name consultDate it's a Hijri date the field is nvarchar(8)
I use this code in a button to retrieve the date
VB
Dim conn As New SqlConnection(Web.Configuration.WebConfigurationManager.ConnectionStrings("UserManagement").ConnectionString)
      Dim comm As New SqlCommand
      Dim adpt As New SqlDataAdapter
      Dim result As New DataTable

      comm.CommandText = "SELECT SUBSTRING(HIJRI_DATE,7,2) AS DAY,SUBSTRING(HIJRI_DATE,5,2) AS MONTH,SUBSTRING(HIJRI_DATE,1,4) AS YEAR FROM TABLE1 "
      comm.Connection = conn
      adpt.SelectCommand = comm
      Try
          adpt.Fill(result)
          DDL_Day.SelectedValue = result.Rows(0).Item("DAY").ToString
          DDL_Month.SelectedValue = result.Rows(0).Item("MONTH").ToString
          DDL_Year.SelectedValue = result.Rows(0).Item("YEAR").ToString
      Catch ex As Exception
          Throw ex
      Finally
          conn.Close()
      End Try
  End Sub

But now I have a gridview and I am using a sqldatasource
the date appears as 01021439
How can I put / between them to make it as a date
Thanks
Posted

Sorry it didn't work
I am using web application
I wrote the code in the GridView1_SelectedIndexChanged should I wrote it in an other place
????
 
Share this answer
 
VB
Dim column1 As New DataGridTextBoxColumn
With column1
    .MappingName = "fieldName"
    .Format = "yyyy/MM/dd"
End With


You can use this for format the date field of your data grid.
This should solve your problem.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900