| Working with DateTime Data Type |
| Sunday, 13 January 2008 | |
|
I have to start importing the whole MS Access database to the new SQL Server database that I have created. In my previous projects (as a VB-classic programmer), I have encountered some issues regarding this data type (DateTime) in SQL Server and my DTPicker tool.
i.e.: Date in database = 19991231 String manipulation: intDate = 19991231 intYr = Left(intDate, 4) intMo = Mid(intDate, 5, 2) intDd = Right(intDate, 2) var = cstr(intYr) & "/" & cstr(intMo) & "/" & cstr(intDd) Output: 1999/12/31
Format Date: stringDate = Format(Date,"yyyymmdd")
To display a NULL value on DTPicker, try using this code:
Private Sub FormatDTPicker() With dtPicker If .value = vbNull Then .format = dtpCustom .customFormat = "X" Else .format = dtpShortDate End If End With End Sub
Private Sub dtPicker_CloseUp() FormatDTPicker End Sub
Private Sub dtPicker_Format(ByVal CallbackField as String, Formatted_String as String) If CallbackField = "X" Then FormattedString = " " End If End Sub
Inside the code sample: dtpBirthday.value = vbNull FormatDTPicker
These have worked for me in VB classic. I am working on a VB.net right now. Will they work still? I have yet to discover.
Lesson learned so far: It's fun to work with databases. I just wish people know that (or I wish I was never that st*pid to submit such proposal!).
I am going to need all the support the net could give me these days.
|
| < Prev | Next > |
|---|


I am Mae German. 34 years old. Born in Mangatarem, province of Pangasinan. I was taught and trained by 



