473,569 Members | 3,040 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

date time formatting

hi,

my sp takes datetime in 'yyyyMMdd HH:mm:ss' format.

however my c# datetimepicker takes 'dd/MM/yy HH:mm:ss' format.

how do i convert/parse the datetime value from the datetimepicker to the sp
datetime format ? I've tried:
eg.
IFormatProvider culture = new CultureInfo("en-US", true);
DateTime dt3 = DateTime.ParseE xact("20080722 10:00:00" , "yyyyMMdd
HH:mm:ss", culture);

No matter what datetime format I pass in, I will always get a "dd/MM/yyyy
HH:mm:ss" format in return, which is not what I want to get. Is my culture
wrong ?

Any advice is appreciated.
Thanks in advance.

regards,
Andrew
Jul 7 '08 #1
4 1383
Andrew <An****@discuss ions.microsoft. com>'s wild thoughts
were released on Mon, 7 Jul 2008 01:51:01 -0700 bearing the
following fruit:
>hi,

my sp takes datetime in 'yyyyMMdd HH:mm:ss' format.

however my c# datetimepicker takes 'dd/MM/yy HH:mm:ss' format.

how do i convert/parse the datetime value from the datetimepicker to the sp
datetime format ? I've tried:
eg.
IFormatProvide r culture = new CultureInfo("en-US", true);
DateTime dt3 = DateTime.ParseE xact("20080722 10:00:00" , "yyyyMMdd
HH:mm:ss", culture);

No matter what datetime format I pass in, I will always get a "dd/MM/yyyy
HH:mm:ss" format in return, which is not what I want to get. Is my culture
wrong ?
Store your date in the format you want in a string and pass
that to your sp.
--
Jan Hyde

https://mvp.support.microsoft.com/profile/Jan.Hyde
Jul 7 '08 #2
my sp takes datetime in 'yyyyMMdd HH:mm:ss' format.

however my c# datetimepicker takes 'dd/MM/yy HH:mm:ss' format.
DateTimePicker. Value Property is a DateTime, no need to go thru a
string and then parse it.
--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
Jul 8 '08 #3
Hi thanks for your reply.

The sp takes datetime in format 'yyyyMMdd HH:mm:ss'
The datetime picket produces a value in format 'dd/MM/yyyy HH:mm:ss'
I just modified the sp to take in a varchar(17) and cast it to a datetime
format.

cheers
Andrew

"Mihai N." wrote:
>
my sp takes datetime in 'yyyyMMdd HH:mm:ss' format.

however my c# datetimepicker takes 'dd/MM/yy HH:mm:ss' format.

DateTimePicker. Value Property is a DateTime, no need to go thru a
string and then parse it.
--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
Jul 8 '08 #4
The datetime picket produces a value in format 'dd/MM/yyyy HH:mm:ss'
Make sure that the result is 'dd/MM/yyyy HH:mm:ss' even for non-US
systems, otherwise you might have a nasty surprise later on.
--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
Jul 9 '08 #5

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

Similar topics

4
10993
by: Gord | last post by:
Hello, VB6 accepts Date and Time values as 'Date'. I'm trying to verify entry into a database I'm creating by verifying that an appropriate Date or Time value has been entered. Using built-in VB functions/properties etc., I can't seem to unambiguously confirm that an entry is a valid date or valid time value? (I would like to try and do...
8
9430
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $ Last-Modified: $Date: 2003/10/28 19:48:44 $ Author: A.M. Kuchling <amk@amk.ca> Status: Draft Type: Standards Track
3
3705
by: RSB | last post by:
Hi Every one , IS there any Date Time Control with .Net. All i want to read is the Date and Time in a Single Field like 12/31/2004 09:23:23AM. if there is any then any examples for it. and if not then how to Validate the Text field for above. thanks RSB
2
1122
by: David | last post by:
I have an application that stores the time information received via the serial port from some hardware. The application needs to compare this time gainst the time received in the last packet and see if the difference is greater than a timeout period that is stored in a database record for that hardware. The data comes in as bytes that are...
3
3280
by: Jim in Arizona | last post by:
I have a gridview that's being populated from an access db query. The problem I'm having is that the date/time fields in access that are populating the gridview are showing both date and time, when the field should only be showing one or the other (date or time). Even on the back end of the database where the column properties are, I have...
0
1631
by: RSH | last post by:
Hi, I have a situation where I am using a dataset from a SQL Query. SQL's DateTime is a "long date/time field" which includes the Date/Time. My fields need to be displayed in a short time format "08:00" instead of "1/1/1900 08:00 AM"? I can't alter the database table, I only want to change the displayed value. How do I either change the...
7
1659
by: christery | last post by:
Anyone got a clue to why ther is a T between date and time in the "formatted for sorting" or whatewer they call it, and a Z at the end after seconds- got it fixed for my cobol programmer by formatting it with yyyy ... aso, made the mistake with mm and MM but got it befre someone saw) but really think its strange, excel dosent like that format...
1
5002
by: Cartoper | last post by:
How does one go about formatting the date/time string correctly to set the If-Modified-Since to the current date/time in an AJAX call? I know I need something like this: request.setRequestHeader('If-Modified-Since','Wed, 05 Apr 2006 00:00:00 GMT'); But I don't know how to actually format the date/time string.
9
5259
by: JeremyI | last post by:
I am writing code to import assessment information about a building from an Excel file (populated by a mobile interviewer on a laptop) into an Access database. With much trial and error, I've hit upon a way of importing all the necessary information, but have run into one last problem when establishing my fully-prepared temporary table to use for...
0
7619
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7930
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7681
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6290
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3662
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.