SQL Server :: DateFormat In SQL Query?
Sep 21, 2010like to get DateFormat "28/07/09 10:29" - "dd/mm/yy hh:mm". My query is below
[Code]....
Which style is fixed this format? Here, time will be shown in 24 hours format.
like to get DateFormat "28/07/09 10:29" - "dd/mm/yy hh:mm". My query is below
[Code]....
Which style is fixed this format? Here, time will be shown in 24 hours format.
using ASP .NET and I'm retrieving data from a MySQL S2005.
I'm using several Jquery Datepickers and I set the dateformat to: "yy/mm/dd".
However, when the datepicker's input field is filled with a date stored in the DB, it
uses different formats, depending on the language of the system.How can I specify a default format? Should I specify this on the DB or directly on the app?
I have a range validator to validate a textbox for birthday. i must ensure that a student must be above 21 to register with us. i set "31/12/1993" format (dd/mm/yy).
but it cannot run the website as in my database is set to this (mm/dd/yy) format. how can i solve this without changing my database format? so that it can function for everyone.
how to format this label.text date as dd/MM/yyyy
Label1.Text = "" + drReaderi["date"].ToString() + "";
I have been struggling with this for a long time. I have a form in which there is a textbox using an ajax calender extender. Now, the problem is that, I want to take the Date value which is string format and format it to a specific date format before inserting it into the database. The following is the core problem:Dim MDate as string=txtMeetingDate.Textdim d as new Datetime ' I want to convert the d to a datetime using the Mdate/// The problem is that I don't know what's the date format in the TextBox because users can use any time format they want, it is based on their windows settings!!!
So, I am struggling to change my String (MDate) into a DateTime in the same format the user have and then convert it into my format:"dd/MM/yyyy" and after I have the date in the correct format, I want to change it back to string and save it in the database.I am doing this so that I have the same dateformat saved in my database.
I have written this query for retrieving data from mysql as below
select FeedbackCode,EMailID,FeedbackDetail,
Date_Format(FeedbackDate,'%m,%d') as 'Feedback_Date'
from FeedbackDetail
where EMailID not like '' and InstanceCode =5
and I'm binding this data with GridView in asp.net but at the column of Feedback_Date,
instead of Date I receive System.Byte[].
By right clicking on my database i created a query in server explorer. But where are this query stored can't find them back. I should aspect that their is a folder query's like there is a folder tables but this isn't the case.
View 10 RepliesI am trying to create statitics for game downloads and am having dificulty with a sub part of my query. the goup by command is not having the disired result and i think i have been looking at it too long to see what i am doing wrong. [Code]....
At the moment it is producing each result in many rows when only 4 rows should appear. its the download column that is doing it. needs to be sub queried or something to display total in relation to month,gameid,userid.
Month-download-GameID-UserID
1 1
1 1
1 1
1 1
I am trying to display this query result in an aspx page.
It is very slow in loading. Here is the query. The inner query inside the outer quesry is the problem.(Please see the underlined part in the query) - (If I remove that part it is very fast.)
select
top 500
--This column is the issue
,Governing_Class=( case when exists (select top 1 tqc.class_code from
t_quote_class tqc
inner join t_quote_class_premium tqcm on tqc.class_code =tqcm.
class_code
where tqc.appid=pi.appid and tqc.class_code not in('8742' ,'8810','7380')
order by tqcm.premium_amt desc
)
then ( select top 1 tqc.class_code from
t_quote_class tqc
inner join t_quote_class_premium tqcm on tqc.class_code =tqcm.
class_code
where tqc.appid=pi.
appid
order by tqcm.premium_amt desc
)
......... From tables
I am a biggner in SQL DB . but i started a complicated and painfull work in SQL SERVER 2008. the problem convert Oracle hierarchical query to SQL query. the query
SELECT DISTINCT
LEVEL LVL,
SCH.NSCHEDULE_SL,
SCH.NSCHEDULE_SL_FM,
SCH.CSHED_CNAME
FROM FA_SCHEDULES SCH
WHERE LEVEL = 1
AND NSCHEDULE_SL_FM IS NULL
AND NBRANCH_SL = 2
CONNECT BY PRIOR SCH.NSCHEDULE_SL_FM = SCH.NSCHEDULE_SL
AND NBRANCH_SL = 2
i have tow query in one stored procedure
first query and the second one every of them return only value
i want to copy the result of tow values in a new row in new table
as i want to check on this tow values in ado.net
i want to get only this tow values as a row not first and secon query
only a row has result of first and second query results
[Code]....
How can I SELECT second if first SELECT returns nothing?
View 8 RepliesUsing sql server 2005.
I have an Query A of fields that returns X number of records.
I create a Query B of same fields that returns X-80 number of records.
I want to find out the 80 records that are in Query A but are not in Query B. what is the syntax for this?
Trying to get a query going in SQL server but I get bad/ errors in the query.I have a 2 tables. One is the "Project" table while the other is the "Task" table.Table structure is as follows.
Project table => ProjectID,ProjectName
Task table => TaskID, TaskName,ProjectID,Quarter, Hours
A project can have many task. The ProjectID in Task table is the foreign key which reference the project ID.What I need to do is to SUM all the hours in the Task table and group it by quarter and then group it by ProjectID. Output of the SQL should be in the form of projectID,Quarter, Hours.
I want to transfer the data from one server to another by sql query. I want query. I dont know how to write?
View 2 RepliesI have the following query that uses a linked server that is on a different VLAN of our network:
[Code]....
It works fine in Query Analyzer but when I put it into Visual Web Developer 2008 Express as a SQL Data Source I get an error:
"OLE DB Provider 'MSDASQL' reported an error. Authentication failed."
In order to terminate a SQL Server query within a VB application, we use the Dispose method to close and dispose the database connection. That has been the only way we have found to actually stop a query from running and release the resources.
However, the next time a new connection is created to the same database, we are getting the error "'ObjectDisposedException - Safe Handle has been closed.". It seems like it is always trying to reuse the disposed connection from the connection pool, and it is not reinitializing it. By using a different connection string, we can avoid the error, since now it's not using the connection pool. But there must be a better way to either stop the query or to reinitialize the disposed connection.
is this correct:
select * from tablename where xyz like 'dan%' and like 'bill%'
i want to list entries where xyz is daniel, bill steffen.....
for some reason i am always getting an incorrect syntax error in the following queryI have tried 2 ways to write this query and both failed, Query 1:
[Code]....
Query 2:
[Code]....
consider the follwing table, this table actually shows which id was given a new id
i.e 11 was assigned 13
again 13 was assigned 15
15 was reassigned 17....and so on actually 11,13,15,17,19 represent the same user (hope u understood)
customerId rejoiningId
11 13
13 15
15 17
20 21
17 19
48 50
21 25
i need to loop through all the rows and find the relation that which all ids are interlinked
say the user enters the rejoining id -13,hence the result should come out to be as 11,13,15,17,19
if user enters 21result should be 20,21,25
it takes a bit of looping statements in query that i couldnt figure out
i have a big query and many data
when i try to execute this query i got this error
how can i run this query complete?
I am new to development and want to know the professional way to deal with dates in SQL Server. In my applications mainly we deal with the DATE datatype and no concern with time part. Also maintaining the format dd/mm/yyyy So for example if I have the table with the following structure.
EmployeeTable
---------------
emp_id int
emp_name varchar(50)
join_date date
and if I want to query "join_date" in between start date and end date and pass the dd/mm/yyyy as stored procedure criteria and want to query.What is the professional way to handle dates? I always convert date in varchar and then do the comparison which I guess is the unprofessional way of doing it.
What's wrong this T-SQL query :
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim SQLData As New System.Data.SqlClient.SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|Database.mdf;Integrated Security=True;User Instance=True")
[code]...
I have a requirement in my app to find out if a certain row exists in a table and then if it does get some fields from another row
I have two parameters an EventId and a UserId.
This is the normal statement I would use to get that row
[Code]....
Then I would check if the result > 0. If it is greater than 0 this is the statement I would use to get the other details
[Code]....
So how can I join this into one statement? This is what I have tried
[Code]....
i am having problems updating my user_tbl and i was wondering if anyone could hely me with the syntax. I am only new to this.
Here is my code :
UPDATE User_tbl
SET User_tbl.user_credit_limit = user_credit_limit - '" +
txtCalender.Text + "'
* product_price
FROM
User_tbl
INNER
JOIN Order_tbl ON
User_tbl.users_id
= Order_tbl.customer_id
INNER
JOIN Order_details_tbl ON
Order_tbl.order_id
= Order_details_tbl.order_id
INNER
JOIN Product_tbl ON
Order_details_tbl.product_id
= Product_tbl.product_id
WHERE
users_id = (select username LIKE '"+ txtUser1.Text.Trim() +"')