473,473 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Is "CDate" a bad thing to use?

It doesnt seem to always pick up the sysem date format properly, for example
if I do CDate("19/07/2005") it seems to return an error, even though my
Regional Settigns are dd/MM/yyyy. It seems to ignore the Regional Settings
and expect US date format everytime.

What is the reccomended alternative to CDate?

Thanks!
Owen

Nov 21 '05 #1
6 10993
DateTime.Parse

"Owen" <sp**@spam.com> wrote in message
news:Cs*****************@newsfe1-win.ntli.net...
It doesnt seem to always pick up the sysem date format properly, for
example if I do CDate("19/07/2005") it seems to return an error, even
though my Regional Settigns are dd/MM/yyyy. It seems to ignore the
Regional Settings and expect US date format everytime.

What is the reccomended alternative to CDate?

Thanks!
Owen

Nov 21 '05 #2
"Owen" <sp**@spam.com> schrieb
It doesnt seem to always pick up the sysem date format properly, for
example if I do CDate("19/07/2005") it seems to return an error,
even though my Regional Settigns are dd/MM/yyyy. It seems to ignore
the Regional Settings and expect US date format everytime.

Maybe the seperator is set to "." instead of "/" in the regional settings?

What is the result of CDate? Is there an exception?
What is the reccomended alternative to CDate?


CDate is recommended, but you can also use Date.Parse.

Armin
Nov 21 '05 #3
On Tue, 19 Jul 2005 13:44:02 GMT, Owen wrote:
It doesnt seem to always pick up the sysem date format properly, for example
if I do CDate("19/07/2005") it seems to return an error, even though my
Regional Settigns are dd/MM/yyyy. It seems to ignore the Regional Settings
and expect US date format everytime.

What is the reccomended alternative to CDate?

Thanks!
Owen


See the msdn help for DateTime.Parse() and DateTime.ParseExact().
Nov 21 '05 #4

"Armin Zingler" <az*******@freenet.de> wrote in message
news:eu**************@TK2MSFTNGP10.phx.gbl...
"Owen" <sp**@spam.com> schrieb
It doesnt seem to always pick up the sysem date format properly, for
example if I do CDate("19/07/2005") it seems to return an error,
even though my Regional Settigns are dd/MM/yyyy. It seems to ignore
the Regional Settings and expect US date format everytime.

Maybe the seperator is set to "." instead of "/" in the regional settings?

What is the result of CDate? Is there an exception?

Hi Armin, I get the following exception:

Cast from string "20/07/2005 09:02:33" to type 'Date' is not valid.
Nov 21 '05 #5
"Owen" <sp**@spam.com> schrieb
It doesnt seem to always pick up the sysem date format properly,
for example if I do CDate("19/07/2005") it seems to return an
error, even though my Regional Settigns are dd/MM/yyyy. It
seems to ignore the Regional Settings and expect US date format
everytime.

Maybe the seperator is set to "." instead of "/" in the regional
settings?

What is the result of CDate? Is there an exception?

Hi Armin, I get the following exception:

Cast from string "20/07/2005 09:02:33" to type 'Date' is not valid.

Sorry, I can't reproduce this using your regional settings. It works here.
Armin
Nov 21 '05 #6

"Armin Zingler" <az*******@freenet.de> wrote in message
news:uk**************@TK2MSFTNGP15.phx.gbl...
"Owen" <sp**@spam.com> schrieb
> > It doesnt seem to always pick up the sysem date format properly,
> > for example if I do CDate("19/07/2005") it seems to return an
> > error, even though my Regional Settigns are dd/MM/yyyy. It
> > seems to ignore the Regional Settings and expect US date format
> > everytime.
>
>
> Maybe the seperator is set to "." instead of "/" in the regional
> settings?
>
> What is the result of CDate? Is there an exception?

Hi Armin, I get the following exception:

Cast from string "20/07/2005 09:02:33" to type 'Date' is not valid.

Sorry, I can't reproduce this using your regional settings. It works here.


Not to worry.

I fixed the problem by editing my web.config to force the culture to "en-GB"
in the <globalization> section.
Owen
Nov 21 '05 #7

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

Similar topics

9
by: Bjorn | last post by:
Hi, I need to determine the hightest date between e.g. "8/3/2004" and "8/4/2004". With this code, i get 'dat2' , which means that "8/4/2004" is higher than "8/3/2004". That 's right. But with...
16
by: PK9 | last post by:
I have a string variable that holds the equivalent of a DateTime value. I pulled this datetime from the database and I want to strip off the time portion before displaying to the user. I am...
1
by: stoppal | last post by:
I have the below function written in VB, and everything works fine EXCEPT that the sql code is not executing correctly. The date field is in the table always shows "12/1/1899 11:59:17 PM" no other...
3
by: Reney | last post by:
I am using Access Database in my program. The column in the table that I am going to use has date/time value with Medium Time selected. (HH:mm). The program is recording a clock in time to this...
9
by: Robin Tucker | last post by:
Hiya, I need to test "relative dates" in my program, such as "last six months" or "last 3 months" or "in the last week" etc. How can I do this with a DateTime structure? ie. If NodeDate...
10
by: Kiran | last post by:
Hi, I am trying to convert a string(Thu Jul 21 00:00:00 UTC+0100 200) to date. I get the following error Cast from string "Thu Jul 21 00:00:00 UTC+0100 200" to type 'Date' is not...
1
by: melda | last post by:
I am a real beginnner in ASP. Due to increasing demands on dynamic website, I've been working on ASP website now. I use a ready to use CMS program and right now I've been trying to combine a calendar...
3
by: Kosmos | last post by:
Hey ya'll...I can't seem to figure out why I'm getting this error message, but it all started when I added the new line of code with the recSet5.AddNew --- when I ran the first line, the logic worked...
7
vikas251074
by: vikas251074 | last post by:
I am getting error above in following code since few days giving tension day and night. How can I solve this? I am facing since Oct.25. in line no. 362 After doing a lot of homework, I am...
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...
1
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...
0
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,...
1
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...
0
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...
0
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...
0
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 ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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...

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.