我正在使用SSIS,我需要改变日期。 如何将String格式的日期(例如14/09/1980)转换为VB.NET中的相同日期格式?
我希望将日期时间格式插入到SQL数据库中。
答案 0 :(得分:4)
在VB.NET中:
' Assume the current culture is en-US.
' The date is Feburary 16, 1992, 12 hours, 15 minutes and 12 seconds.
Dim myDateTimeValue As String = "2/16/1992 12:15:12"
Dim myDateTime As DateTime = DateTime.Parse(myDateTimeValue)
' Reverse month and day to conform to a different culture.
' The date is Feburary 16, 1992, 12 hours, 15 minutes and 12 seconds.
Dim cultureGB = New CultureInfo("en-GB", True)
Dim myDateTimeValue As String = "16/2/1992 12:15:12"
Dim myDateTime As DateTime = DateTime.Parse(myDateTimeValue, cultureGB)
' Dsiplay the date in DD/MM/YYYY format
Debug.Print Format(myDateTime ,"dd/MM/yyyy")
参考:http://msdn.microsoft.com/en-us/library/1k1skd40(VS.80).aspx
在VB6中:
dim dt as date
dim s as string
s="10/09/2009"
dt = cdate(s)