473,385 Members | 1,372 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.

Date Time Casting Problem

ed
I read a similar post on the group :

http://groups.google.co.uk/groups?q=...tngp05&rnum=15

I'm having a similar problem.

My set up is : windows 2000 sever (all regional settings set to
british / UK)
SQLserver 2000 : (user account has default lang set to british (UK))
..net framework erm... 1.1.4322 i think.

when i run the following sql in the querry anylser it works fine:
SELECT t_reminder.intReminderID,Convert(char(10),t_remind er.dtmReminderDate,103)
FROM t_reminder ORDER BY t_reminder.dtmReminderDate ASC
Put it in as aspx page and i get an error:
Cast from string "30/07/2004" to type 'Date' is not valid.

Using the following command as detailed in the above article:
Response.Write(System.Threading.Thread.CurrentThre ad.CurrentCulture.EnglishName)
I got English (United States).

I'm tearing my hair out (what little I have) over this.. does any one
have any ideas??
Nov 20 '05 #1
2 1594
"ed" <ed@remote.uk.com> schrieb
I read a similar post on the group :

http://groups.google.co.uk/groups?q=...tngp05&rnum=15
I'm having a similar problem.

My set up is : windows 2000 sever (all regional settings set to
british / UK)
SQLserver 2000 : (user account has default lang set to british
(UK)) .net framework erm... 1.1.4322 i think.

when i run the following sql in the querry anylser it works fine:
SELECT
t_reminder.intReminderID,Convert(char(10),t_remind er.dtmReminderDate,103)
FROM t_reminder ORDER BY t_reminder.dtmReminderDate ASC
Put it in as aspx page and i get an error:
Cast from string "30/07/2004" to type 'Date' is not valid.

Using the following command as detailed in the above article:
Response.Write(System.Threading.Thread.CurrentThre ad.CurrentCulture.EnglishN
ame) I got English (United States).

I'm tearing my hair out (what little I have) over this.. does any
one have any ideas??


Why not use the format the server is expecting in an SQL string? I think the
format #07/30/2004# should work. To convert a date value to this string use
"#" & <DateTime>.ToString("MM/dd/yyyy") & "#". I'm not sure if that's
exactly the format the server expects but you can look it up in the T-SQL
manual.

I guess you are using ADO.NET. The question is not specific to VB.NET
programming, so I think microsoft.public.dotnet.framework.adonet is the more
appropriate group.

You should also have a look at the Parameters property and have ADO.NET
create the complete SQL string for you.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
I had a similar problem, the result I found was that SQL
formats all dates as mm/dd/yy irrespective of system date
therefore all dates processed should first be formated
mm/dd/yy

hope this helps

-----Original Message-----
"ed" <ed@remote.uk.com> schrieb
I read a similar post on the group :

http://groups.google.co.uk/groups?

q=.net+cast+string+date+valid+sql&start=10&hl=en&l r=&ie=UTF
-8&oe=UTF-8&selm=eRvILbWECHA.1548%40tkmsftngp05&rnum=15

I'm having a similar problem.

My set up is : windows 2000 sever (all regional settings set to british / UK)
SQLserver 2000 : (user account has default lang set to british (UK)) .net framework erm... 1.1.4322 i think.

when i run the following sql in the querry anylser it works fine: SELECT
t_reminder.intReminderID,Convert(char (10),t_reminder.dtmReminderDate,103) FROM t_reminder ORDER BY t_reminder.dtmReminderDate ASC
Put it in as aspx page and i get an error:
Cast from string "30/07/2004" to type 'Date' is not valid.
Using the following command as detailed in the above article:

Response.Write

(System.Threading.Thread.CurrentThread.CurrentCult ure.Engli
shName)
I got English (United States).

I'm tearing my hair out (what little I have) over this.. does any one have any ideas??
Why not use the format the server is expecting in an SQL

string? I think theformat #07/30/2004# should work. To convert a date value to this string use"#" & <DateTime>.ToString("MM/dd/yyyy") & "#". I'm not sure if that'sexactly the format the server expects but you can look it up in the T-SQLmanual.

I guess you are using ADO.NET. The question is not specific to VB.NETprogramming, so I think microsoft.public.dotnet.framework.adonet is the moreappropriate group.

You should also have a look at the Parameters property and have ADO.NETcreate the complete SQL string for you.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

.

Nov 20 '05 #3

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

Similar topics

4
by: Frank Rocco | last post by:
Hello, What is the best way to validate a textbox to see if it contains a valid date or a valid time or both? Thanks Frank
3
by: Martin | last post by:
Hi, I have what is probabally a date contained in an object variable. Before casting to date I actually want to attempt to verify that I actually have a date. I prefer to do this before casting...
1
by: Baris - Izmir | last post by:
Hi, I have a web form and this form takes a date data from user and stores it to database (SQL). I written a store procedure to perform this but when I do not fill the date textbox, SQL gives an...
12
by: DC Gringo | last post by:
How can I convert this pubLatest to a date with format "m/d/yyyy"? Dim pubLatest As New Date pubLatest = Me.SqlSelectCommand1.Parameters("@pubLatest").Value -- _____ DC G
3
by: Rob Bradford | last post by:
All. I have three variables M, D, and Y that take input from DomainUpDown (prefix dud_) and NumericUpDown (prefix nud_). How do I cast these into a valid date-time data type? The...
3
by: Kevin Hodgson | last post by:
I'm trying to import from a text file into a Sql DB, but I'm getting hung up on a date field. My text file has the date in the dd/mm/yyyy format. I Cast that field to CDate in VB.NET, which sets...
1
by: Budd | last post by:
Hi everyone i got a problem on date, it is... 1, i get the date from calendar component 2, compare today and selected date is equal (compare method) 3 count the number of day between this...
2
by: syntego | last post by:
We commonly use triggers to log changes to our main tables to historical log tables. In the trigger, we create a concatenated string of the old values by casting them as follows: ...
44
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
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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?

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.