| re: problem with date format
Sam,
Both the DateTime and the SmallDateTime are culture independend.
From MSDN about SmallDateTime
The first 2 bytes store the number of days after January 1, 1900. The other
2 bytes store the number of minutes since midnight. Dates range from January
1, 1900, through June 6, 2079, with accuracy to the minute.
Therefore the value from your datetimepicker is already in the right
datetime format.
ciDatabase = datetimepicker.value should be enough.
I hope this helps,
Cor
"Sam" <replyfromforum@hotmail.co.uk> schreef in bericht
news:1134481647.384014.14890@z14g2000cwz.googlegro ups.com...[color=blue]
> Hi,
> I store the date selected in a datetimepicker into a sqlserver table in
> a SmallDateTime field.
> To be compatible with the date format of my sql server, I convert the
> date as following:
>
> Dim d As Date
> Dim dInDate As Date
>
> Dim ciOriginal As cultureinfo
> Dim ciDatabase As cultureinfo
>
> ciOriginal = Thread.CurrentThread.CurrentCulture
> ciDatabase = CultureInfo.CreateSpecificCulture("en-US")
>
> Thread.CurrentThread.CurrentCulture = ciDatabase
>
> dInDate = Date.Parse(Data("ExpiryDate").ToString)
>
> d = Date.Parse(Data("ExpiryDate").ToString)
>
> It works fine. Issue is : how to get the sqlserver date format as I
> don't want to hardcode en-US as I do above.
>
> Thanks!
>[/color] |