Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
If con.State Then con.Close()
con.Open()
ts = con.BeginTransaction
sqlselect.Connection = con
sqlselect.Transaction = ts
sqlselect.CommandText = "alter table Client_Details add Client_SMS_BDt date,Client_SMS_ADt date, BdayYear text(100), AnYear text(100), MonDate date"
    sqlselect.ExecuteNonQuery()


System.Threading.Thread.Sleep(500)

sqlselect.CommandText = "Update  Client_Details set Client_SMS_BDt =0,Client_SMS_ADt =0, BdayYear='', AnYear ='', MonDate =0"
    sqlselect.ExecuteNonQuery()



ts.Commit()


MsgBox("DONE")



Catch ex1 As Exception
    ts.Rollback()
End Try



after executing above code the data in ms access mdb file

Client_SMS_BDt is 12:00:00 AM
Client_SMS_ADt is 12:00:00 AM
MonDate is 12:00:00 AM

how can i format date field (Client_SMS_BDt) as short date while adding column

please help!
Posted
Comments
Richard MacCutchan 16-Jan-14 4:02am    
You have set all date values to 0 so that is why they are showing as 12:00 AM. If you wish to see them in some other format then use an appropriate format string template. I would suggest you also get rid of the BdayYear, AnYear and MonDate fields, and make proper use of your dateTime fields.
Omkaara 16-Jan-14 4:12am    
it will show 30/12/1899 if format is change to Short Date
my question is how to change format while adding column itself
Richard MacCutchan 16-Jan-14 4:27am    
The format has nothing to do with the column. The column is a DateTime value, and the only time a format has any relevance is when you wish to display its content in human readable form.
Omkaara 16-Jan-14 4:59am    
but i need to check the values from the above fields i cant format the value and check
Richard MacCutchan 16-Jan-14 5:12am    
What do you mean? Checking the values has nothing to do with how they may be formatted.

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