【发布时间】:2009-11-20 16:04:18
【问题描述】:
我正在使用SSIS,我需要转换日期。 如何在 VB.NET 中将字符串格式的日期(例如 1980 年 9 月 14 日)转换为相同但日期格式?
我希望将日期时间格式插入 SQL 数据库。
【问题讨论】:
我正在使用SSIS,我需要转换日期。 如何在 VB.NET 中将字符串格式的日期(例如 1980 年 9 月 14 日)转换为相同但日期格式?
我希望将日期时间格式插入 SQL 数据库。
【问题讨论】:
在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)
【讨论】: