| | |
formatting in sql server
Please support our MS SQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved
![]() |
In your Select statement add this
SQL Syntax (Toggle Plain Text)
SELECT CONVERT(VARCHAR(5), [dateTimeColumn], 14), ..... FROM [table name];
Last edited by Ramy Mahrous; Dec 23rd, 2008 at 10:27 am.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Dec 2008
Posts: 37
Reputation:
Solved Threads: 0
Now my sql statement looks like this:
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
sql Syntax (Toggle Plain Text)
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
Last edited by peter_budo; Dec 24th, 2008 at 6:43 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Because your SQL Syntax is wrong
the right one is
the right one is
sql Syntax (Toggle Plain Text)
SELECT CONVERT(VARCHAR(5), [dateTimeColumn], 14) , txt FROM PROGRAM WHERE DATE >= convert(VARCHAR, GETDATE()) AND DATE <= DATEADD(MONTH, 2, GETDATE())";
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
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.
Tell me your table columns if you faced another problem.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Dec 2008
Posts: 37
Reputation:
Solved Threads: 0
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?
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?
Remove the container control (DataList, Repeater, etc...) and insert someone again... or try asking asp.net forum http://www.daniweb.com/forums/forum18.html
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
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.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
![]() |
Similar Threads
- How can show/view Infopath dynamic files(xml) without infopath in a computer (XML, XSLT and XPATH)
- C# and mycrosoft sql server 2k8? (C#)
- Backup of sql server using vb.net code (VB.NET)
- Problem in finding birthday from date of birth in SQL Server (MS SQL)
- The Definitive Guide to which Forum Software Information (Growing an Online Community)
- Special formatting of a GridView... (ASP.NET)
- How do you integrate a database w/web design? best solution for online catalogue? (Database Design)
Other Threads in the MS SQL Forum
- Previous Thread: Add SUM and AVG together also SUM and COUNT together
- Next Thread: mySQL UPDATE is adding erroneous spaces, special characters
| Thread Tools | Search this Thread |






