![]() |
| ||
| Re: formatting in sql server In your Select statement add this select CONVERT(VARCHAR(5), [dateTimeColumn], 14), ..... from [table name]; |
| ||
| Re: formatting in sql server Now my sql statement looks like this: SELECT CONVERT(VARCHAR(5), [dateTimeColumn], 14) * FROM PROGRAM WHERE DATE >= convert(varchar, GETDATE()) AND DATE <= DATEADD(Month, 2, GETDATE())"; the column that there is a problem with is not a dateTime. It is varchar(50). her you can see the error message: http://radio.web.surftown.dk/udsendelser.aspx |
| ||
| Re: formatting in sql server Because your SQL Syntax is wrong the right one is SELECT CONVERT(VARCHAR(5), [dateTimeColumn], 14) , txt FROM PROGRAM WHERE DATE >= convert(varchar, GETDATE()) AND DATE <= DATEADD(Month, 2, GETDATE())"; |
| ||
| Re: formatting in sql server ok now there is another error: Invalid column name 'dateTimeColumn'. What is there supposed tol be in: [dateTimeColumn]? I think that is the problem. |
| ||
| Re: formatting in sql server Kischi, it seems you in hurry!!! please be patient and think in codes before writing it. dateTimeColumn isn't column in your table program, rather I mean the column holds the date data. Tell me your table columns if you faced another problem. |
| ||
| Re: formatting in sql server I'm sorry that I was in such a hurry. But I actually tried something else, but it didn't work. I have 4 columns in the db. Here is hor it looks with the datatypes: ID(bigint) tid(varchar(50)) txt(text) date(datetime) It is tid that writes it like this: 30-12-1899 18:00:00 so that is the one I want to format. so now I wrote [tid] instead of [dateTimeColumn] But now I get another error: DataBinding: 'System.Data.Common.DataRecordInternal' does not contain a property with the name 'tid'. You can see it on: http://radio.web.surftown.dk/udsendelser.aspx Hope this helps? |
| ||
| Re: formatting in sql server Remove the container control (DataList, Repeater, etc...) and insert someone again... or try asking asp.net forum http://www.daniweb.com/forums/forum18.html |
| ||
| Re: formatting in sql server I found out that it has nothing to do with my coding. It is excel that writes: 30-12-1899 18:00:00 when I write 18:00 automatically. So do you know anything about excel, because have tried to change it so it dousn't do it, but I don't know how? Thanks Kischi |
| ||
| Re: formatting in sql server let your SQL holds the date in any format, we won't care!!! what I care about? is date when returns, I suggest you a SQL statement to solve all of your problems. |
| ||
| Re: formatting in sql server But is that also possible when the datatype of the column is "Varchar(50)" and it is not "datetime" |
| All times are GMT -4. The time now is 7:45 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC