Last Post 10 Jul 2003 05:36 PM by BAnVA. 0 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
BAnVA
New Member
New Member

--
10 Jul 2003 05:36 PM
The default format for converting strings to dates in SQL Server is month/day/year. You are formatting the date strings as day/month/year which may be causing a problem if the day portion of the date is greater than 12. You can change the sequence of date strings for the connection in SQL Server by running SET DATEFORMAT dmy. However, I would just change your VB code to format the date in month/day/year format.

Example:

fDate_time = fMonth.Text + "/" + fday.Text + "/" + fYear.Text + " " + fHour.Text + ":" & _
fmin.Text + ":" + fsec.Text + " " + fAMPM.Text

Hope I'm not overstepping my boundaries but here are a couple of coding recommendations.

1) Don't use the + sign in VB 6 to concatenate strings together. Use the & instead for string concatenation. The + sign can cause unexpected results when one of the values being concatenated is null or isn't a string.

2) You might want to encapsulate your date concatenation inside a method that takes the individual parts of the date as parameters and returns a string with the parts concatenated and formatted.
You are not authorized to post a reply.

Acceptable Use Policy