473,837 Members | 1,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date Conversion probs

Hello,

I am trying to convert a date from a string like this:

Dim dtDate As DateTime = Convert.ToDateT ime("Sun, 07 Nov
2004 14:05:04 +0200")
Response.Write( dtDate.ToString ("dd MMM yyyy"))

However I am getting the error:

"String was not recognized as a valid DateTime. "

Its because of the "+200". What is the best way to convert
such a date?

Thanks
Nov 18 '05 #1
4 1286
Are you asking how to preserve the time zone information in the datetime,
how to adjust for the times zone, or how to lop off the last five characters
of the string to make it acceptable?

"Vishal" <an*******@disc ussions.microso ft.com> wrote in message
news:4c******** *************** *****@phx.gbl.. .
Hello,

I am trying to convert a date from a string like this:

Dim dtDate As DateTime = Convert.ToDateT ime("Sun, 07 Nov
2004 14:05:04 +0200")
Response.Write( dtDate.ToString ("dd MMM yyyy"))

However I am getting the error:

"String was not recognized as a valid DateTime. "

Its because of the "+200". What is the best way to convert
such a date?

Thanks


Nov 18 '05 #2
Hello Ken,

I simply want to convert the "Sun, 07 Nov
2004 14:05:04 +0200" to a valid date. Nothing more and
nothing less.

Vishal
-----Original Message-----
Are you asking how to preserve the time zone information in the datetime,how to adjust for the times zone, or how to lop off the last five charactersof the string to make it acceptable?

"Vishal" <an*******@disc ussions.microso ft.com> wrote in messagenews:4c******* *************** ******@phx.gbl. ..
Hello,

I am trying to convert a date from a string like this:
Dim dtDate As DateTime = Convert.ToDateT ime("Sun, 07 Nov
2004 14:05:04 +0200")
Response.Write( dtDate.ToString ("dd MMM yyyy"))

However I am getting the error:

"String was not recognized as a valid DateTime. "

Its because of the "+200". What is the best way to convert such a date?

Thanks


.

Nov 18 '05 #3
Just trim the last five or six characters before the conversion.

"Vishal" <an*******@disc ussions.microso ft.com> wrote in message
news:43******** *************** *****@phx.gbl.. .
Hello Ken,

I simply want to convert the "Sun, 07 Nov
2004 14:05:04 +0200" to a valid date. Nothing more and
nothing less.

Vishal


Nov 18 '05 #4
I was hoping for a conversion solution, but I think there
isnt any. Thanks anyway for your help Ken.

-----Original Message-----
Just trim the last five or six characters before the conversion.
"Vishal" <an*******@disc ussions.microso ft.com> wrote in messagenews:43******* *************** ******@phx.gbl. ..
Hello Ken,

I simply want to convert the "Sun, 07 Nov
2004 14:05:04 +0200" to a valid date. Nothing more and
nothing less.

Vishal


.

Nov 18 '05 #5

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

Similar topics

3
3748
by: praba kar | last post by:
Dear All, I have doubt regarding date string to time conversion function. In Python I cannot find flexible date string conversion function like php strtotime. I try to use following type function 1) parsedate function failed if a date string like below format "16-MAY-2005 01:26" 2)parsedate_tz function also failed if a date string
1
3607
by: Riley DeWiley | last post by:
I have an UPDATE query that is always setting 0 records. When I cut and paste the SQL into Access and use it, it fails in the same way unless I coerce the date fields to be '=now()', in which case it works. I never get errors, and if I don't try to update the date fields, I always update the expected number of rows (1). When I do date conversion using the same conversion function, then call CRowset::Add() to add a record to the same table,...
10
1686
by: melissa.nava | last post by:
Here is my code: ***** Public Property DOB() As Date Get Try DOB = (msBirthMonth + "/" + msBirthDay + "/" + msBirthYear)
1
1845
by: Graham Feeley | last post by:
I have a date field named rcdate it is a general date eg: 12/08/2006 3:30:00 PM 12/08/2006 3:00:00 PM I used to update another empty field named rdate with the with using in a update query " Left(Ratings!RCDate,10)" This now does not work for some reason gives me the error "undefined function in left function"
15
5969
by: edouard.spooner | last post by:
Hi, I have a tricky SQL query problem that I'm having probs with. I have a table which resembles something like this Date | Price1 | Price2 | Price3 01 Jan 2006 | 100 | 100 | 100 02 Jan 2006 | 100 | 100 | 100 03 Jan 2006 | 100 | 100 | 100
44
10253
by: user | last post by:
Hi, Let's say I have 2 dates in the b/m format: Date 1 and date 2 How do I check whether Date2 is later than Date 1? Date1. 21-Nov-2006 09:00:00 PM
7
3016
by: bruce.dodds | last post by:
Access seems to be handling a date string conversion inconsistently in an append query. The query converts a YYYYMM string into a date, using the following function: CDate(Right(,2) & "/1/" & Left(,4)) I entered the string "200715" in a record to test an error condition.
4
1791
by: g0uki | last post by:
Hi all, Hope someone can help, i get the date in the format of 12/12/2008 i 'd like to find out what day this is on, either a weekday/weekend. so output would be: 12/12/2008 midweek: fri 12 december I'm also trying to do it the hard way, without the use of any modules .. i feel this will help my perl skills.
2
5157
by: RN1 | last post by:
A TextBox displays the current date (in dd/mm/yyyy format) & time when a user comes to a page (e.g. 15/10/2008 1:36:39 PM). To convert the date into international format so that the remote server doesn't generate any error, this is what I am doing: --------------------------- Dim strSDate As String Dim strSTime As String Dim strStartDT As String Dim strSDateTime As String
0
9837
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9682
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10870
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10267
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6998
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5668
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4474
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4038
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3123
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.