473,385 Members | 2,274 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

problem with date format

Sam
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!

Dec 13 '05 #1
3 1952

Sam wrote:
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)


Hang on. Data("ExpiryDate") comes from SQL, and it's a date, so why
convert it to a string (creating culture issues)? A SqlDateTime can be
directly converted to a Date - this avoids all culture issues.

--
Larry Lard
Replies to group please

Dec 13 '05 #2
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" <re************@hotmail.co.uk> schreef in bericht
news:11*********************@z14g2000cwz.googlegro ups.com...
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!

Dec 13 '05 #3
Sam
Hi guys,
Thanks a lot for your replies.
In fact, I had trouble with that because I was doing
datetimepicker.Text instead of datetimepicker.value as Cor suggested.

It works now. ;-)
Thank you.

Dec 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Lyn | last post by:
Hi, I am developing a project in which I am checking for records with overlapping start/end dates. Record dates must not overlap date of birth, date of death, be in the future, and must not...
6
by: Willie wjb | last post by:
Hi, i have a client program that sends a filter expression to the server PC. On that server PC this filter is put over a datatable and the result is send back. the server can be located on a...
11
by: Geoff Jones | last post by:
Hi I have a table that has a column with Date types. I am trying to view certain rows in the table using a DataView. Using the filter, I can view the rows with, for example, the date equal...
12
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as...
3
by: Steven Smith | last post by:
Hi everyone, This code makes sense to me, but when I run it, it says "Loop Without Do". Any Suggestions? Thanks, Steven Smith Dim FirstPaymentDate As Date
16
by: Mik | last post by:
I apologise if this post seems a little basic, but I am a newbie and have NO access knowledge. I have downloaded the Accounts Ledger from the Microsoft Website. It allows the user to review a...
0
by: mykhan | last post by:
I have been using access database with asp.net pages. I just realized a problem with date saving in access table. I didnt give any specific format for the date when saved in tables, because I wanted...
7
by: creative1 | last post by:
Hello everyone. I am experiencing a strange problem that I can't fix on my own. I think I need expert's suggestions for this. The problem is: I want to print account statement (or any other...
1
by: swathichavalla | last post by:
Problem description: Clients working with an apple computer with the safari browser are experiencing problems with brokerage orders. When the client wants to enter a stock order, the order entry...
11
by: jessy | last post by:
Hi, I have a problem with my DateTimePicker javascript code which i downloaded , the problem is when i pick the date and the date appears in my Text Field and i click Submit the date which i picked...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.