473,405 Members | 2,310 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,405 software developers and data experts.

String Convert to Date Time Problem is Windows 98

I use the vb.net make the program that save the date and any Information
field.
when I input the date in textbox then I save to database occurs error that
is
"Cast from string "20/08/2003" to type 'Date' is not valid.
I use this command change string to Date
dim year as date
dim strYear as string
=> year = ctype(stryear,Date).ADDYEAR(2)
I only in Windows 98 have problem
but In windows XP is not problem.
What wrong, and how can solve this problem and this commands have any error?

Nov 20 '05 #1
2 11075
Hello,

"Ryanfai" <ry*****@yahoo.com> schrieb:
I use the vb.net make the program that save the date
and any Information field.
when I input the date in textbox then I save to database occurs
error that is
"Cast from string "20/08/2003" to type 'Date' is not valid.
I use this command change string to Date
dim year as date
dim strYear as string
=> year = ctype(stryear,Date).ADDYEAR(2)
I only in Windows 98 have problem
but In windows XP is not problem.
What wrong, and how can solve this problem and this
commands have any error?


I think that's caused by the format of the string (maybe it violates with
the locale settings of the computer). You may want to use 'DateTime.Parse'
instead.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #2
Pass your date to this function and it will work fine.

Function ISODate(ByVal dteDate As Date) As String
If IsDate(dteDate) = True Then
Dim dteDay, dteMonth, dteYear
dteDay = dteDate.Day
dteMonth = dteDate.Month
dteYear = dteDate.Year
ISODate = dteYear & _
"-" & Right(CStr(dteMonth + 100), 2) & _
"-" & Right(CStr(dteDay + 100), 2)
Else
ISODate = Nothing
End If

End Function
--
Dino Buljubasic
Software Developer
http://rivusglobal.com

"Ryanfai" <ry*****@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I use the vb.net make the program that save the date and any Information
field.
when I input the date in textbox then I save to database occurs error that
is
"Cast from string "20/08/2003" to type 'Date' is not valid.
I use this command change string to Date
dim year as date
dim strYear as string
=> year = ctype(stryear,Date).ADDYEAR(2)
I only in Windows 98 have problem
but In windows XP is not problem.
What wrong, and how can solve this problem and this commands have any error?

Nov 20 '05 #3

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

Similar topics

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...
10
by: Kim Hellan | last post by:
I have a simple string in the format "DD-MM-YY hh:mm:ss", that I need to convert to a DateTime value. I know this is a standard problem, but please don't just link to all the MSDN pages regarding...
3
by: Alpha | last post by:
I have 2 strings, "12/28/2005" and "16:44:54". I need to conatenate them and convert them to datetime format so I can assign them to a datetime field in a datarow. The time is now being converted...
11
by: jwf | last post by:
I am writing a NON MFC C++ application (Plug-in for a 3rd party DB system). The application is designed to synchronise data between MS Outlook and the DB system. I am using smart pointers for the...
1
by: jwf | last post by:
This question continues on from a previous post "DATE to string" but I think it deserves a new thread. In my previous post I was trying to convert a DATE to string in a NON MFC C++ application...
22
by: j1mb0jay | last post by:
I have had to create a simple string encryption program for coursework, I have completed the task and now have to do a write up on how it could be improved at a later date. If you could look...
8
by: deepak_kamath_n | last post by:
Hello, I have the following scenario: 1. My application receives the date from another application as a string 2. The other application is running in a different time zone as compared to my...
3
by: Jef Driesen | last post by:
How can I convert a date string to a number (e.g. a time_t value or a tm struct)? I know about the strptime function, but then I have to know the format string. And that is a problem. I'm trying...
4
by: Nathan Sokalski | last post by:
When determining whether a String can be converted to a DateTime, you can use the IsDate() method. However, I would also like to know whether the string is a date, a time, or both a date and a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
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...
0
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...

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.