.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan
Post New Web Links

using sql query how to get the day of the respective date which i have given

Posted By:      Posted Date: September 23, 2010    Points: 0   Category :Sql Server
 

how to select * from query

that has to show in this formatt(monday,tuesday...........sunday)

if suppose my date is 09/23/2010 then the ans should be thursday

anybody knows the query please tell me




View Complete Post


More Related Resource Links

Need help in Date Query

  
HI Guys I have date like 2008-10-31 16:36:567 I want to convert like 20081031 00:00:000 for this I'm using convert(datetime,(convert(varchar(8),replace('2008-10-31 16:36:567','-','')))) is there any option to do this?

Need to convert query string(date - 09/15/2010) to a text format - yyyymmdd

  
I am fairly new to C # and need some assistance with a form page.  I have created a simple form that requires the user to select a beginning date and ending date.  I then pass the values to my code behind page via query strings.  I have them passing, but I need the format to be change to a different format.  Unfortunately the database does not use the standard date format.  It requires the date to be in a text format as YYYYMMDD.Form: <tr> <td> Beginning Date:</td> <td><asp:TextBox runat="server" ID="begDate"></asp:TextBox> <asp:Image ID="Image2" ImageUrl="~/images/calendar_schedulehs.png" runat="server" /></td> </tr> Code Behind: protected void createReport_Click(object sender, EventArgs e) { StringBuilder url = new StringBuilder("Report/TopCustomer.aspx?"); url.Append("BegDate=" + begDate.Text); url.Append("&EndDate=" + endDate.Text); url.Append("&Brnch=" + ddlLocation.SelectedValue); Response.Redirect(url.ToString()); Current URL: TopCustomer.aspx?BegDate=09/15/2010&EndDate=09/30/2010&Brnch=300I need to have the above URL change to:TopCustomer.aspx?BegDate=20100915&E

parameterized query and Date Field

  
Hi!Using this SQL:SELECT fac_op_d.cod_art_i, SUM(fac_op_d.cantidad) AS total, inv_mp_m.nombre, fac_op_d.fec_doc FROM fac_op_d, inv_mp_m WHERE fac_op_d.cod_art_i = inv_mp_m.cod_art_i AND (fac_op_d.cod_art_i LIKE ? + '%') AND (inv_mp_m.almacen = 1) AND (fac_op_d.fec_doc BETWEEN ? AND ?) GROUP BY fac_op_d.cod_art_i, inv_mp_m.nombre, fac_op_d.fec_docThis is a query to an old FoxPro database on a server (Same Network). This work in the execution, but just passing the date values as aaaa/mm/dd.On my page when a pass two DateTime Parameters from two TextBox it throw "Unable to recognize the string as a valid DateTime Value"I'm using Ajax Calendar exterder on the textbox to be more specific.Here, (My Country)  the format i'm using es dd/mm/aaaaAnd when i select the datepicker it comes in this format, and then a get the DateTime error type.I can get the rows in the query builder just passing the date like "2010/01/15" and "2010/01/30" for example.Hay can i force the texbox to get this format aaaa/mm/dd?regards

T-SQL query, average of daily time periods over a date range

  

Hi,

I'm building a report in Crystal Reports using a SQL command against a T-SQL 2005 telephony database.

I need to be able to run the query across a given datetime range, 6 months for example and bring back a 5 day display (Mon-Fri) with a group for every 15 minute interval in each day.

The group figures need to contain an average of the amount of calls presented for each 15 minute interval on any day across the whole datetime range, so for example the Monday 10:00 - 10:15 figure would be an average of all calls presented in every 10:00-10:15 range on each of the Mondays that fall within the datetime range.

I've got a query built now that gives total presented figures grouped by these intervals across one week but I can't figure out how to do this average function across a range.

Does anyone have any idea how I'd go about accomplishing this? I'm pretty new to SQL but keen to learn so any pointers on functions to research etc would be very much appreciated.

Thanks alot in advance, Andy.

Query for detail view across one week included below for table/fields etc...

 

SELECT

count(DISTINCT Calls.SessionID) as Presented, min(Calls.startDateTime) as DateTime

FROM
Calls
INNER JOIN QueueDetail
ON Calls.sessionID =  Queues.sessionID
AND Calls.sessionSeqNum =  QueueDet

Query acting weird.. larger date range works in 1min 26sec and a smaller range say 1 month - 3 month

  

I have no clue why my query is acting weird

If i try to run it for 1/1/2010 9/30/2010 the query takes around 1min 26 sec and  return around a million rows

and If i run for 8/1/2010 to 8/31/2010 it takes forever to it...

basically i am getting data from 5 tables and putting it in a temp table and then updating that temp table 2-3 times with some information and then displaying it.

I am stumped as to why it works fast for a longer date range and runs the  snail for a small period of time..

I am in the verge of pulling my hair and going crazy..

any help will be appreciated.

 

Thanks

Karen


SQL Query for Date Check User Dates

  

Hi

I am using two columns in one table such as StartDate,Enddate.

In asp.net Form two text boxes there. One is StartDate other one EndDate..

When user Click Submit button the Two dates is compare above DataFiled's...

-----Examble:------

-------- Data Base Values ----------------

StartDate            EndDate

--------------------------------

10/09/2010         14/09/2010

16/09/2010         28/09/2010

--------------------------------------------------------

 

user send Start Date ' 27/09/2010' and EndDate '30/09/2010'

 

Now the Query Check Dates Between Userdates avialable in Database....

 

What I ll do?????

 

(Note : Opertion only allow the Dates Not Exists in Database Dates)

 

 


Issue with CAML Query regarding date comparision.

  
I have a below query in one the eventhandlers. All I do in the query is to get all records where Next_Date column is < CurrentDateTime ( I have shown current date below in full date format but it will be variable).

What I am observing is the comparision seems to be failing or not considering time format. For example the below query should not return any records when NEXT_DATE is 9/30/2010 23:59:59 and CurrentDateTime is 9/30/2010 06:22:22. However the query does return records. It looks like the comparision is just happening with Date and not time. What could be the problem? Please suggest.

<Query>
   <Where>
      <Leq>
         <FieldRef Name='Next_x0020_Date' />
         <Value Type='DateTime'>2010-09-30T13:13:13Z</Value>
      </Leq>
   </Where>
   <OrderBy>
      <FieldRef Name='Next_x0020_Date' Ascending='False' />
   </OrderBy>
</Query>

query wich returns records for each day between start date from table 1 and mutation dates in table

  

Hello,

I have to tables with dates, table Employments with all employements of all employees, with start date and end date, and a table Mutations with mutations (e.g in salary) with start dates.

Now I try to write a query which returns a record for each day an employee is in employment, with the correct salary. SO at first, it should return all days between the employment start date and the first mutation date, then the number of days between the first mutation date and the second mutation date etcetc, and at last the number of days between the last mutation date and the employment end date. The number of mutations varies for each employment, and employees cna have multiple employments (history, so not at the same time) in the employments table.

How to do this?


problem with date range between select Query in data adapter

  

hi all,

can any one help me out...why am getting "data type mis match error"

 DateTime dFromDate = dt_From.Value;
            dt_From.Value = DateTime.Parse(dFromDate.ToShortDateString());
            string From = dFromDate.ToShortDateString();

            DateTime dToDate = dt_To.Value;
            dt_To.Value = DateTime.Parse(dToDate.ToShortDateString());
            string To = dToDate.ToShortDateString();
            OleDbConnection cn = new OleDbConnection(ConfigurationSettings.AppSettings["connec"]);
            cn.Open();
            OleDbDataAdapter da = new OleDbDataAdapter("select * from Route_Expenses a where Entry_Date between '" +From+"' and '"+To+"'",cn);
            DataSet ds = new DataSet();
            da.Fill(ds);
            dataGridView1.DataSource = ds.Tables[0];


 Please..its Urgent!


Sharepoint designer 2007 - Java date query - and how to disable value required for hidden fields

  

Hi guys,

created a list, i've managed to get field to hide and dates to populate into the applicable fields, I just have 2 queries taht I need some help with

>I need to work out how to get var tmoz to ignore saturdays and sundays - i.e. if request is raised on fri - it would default to the following mondays

>I need to work out how to mark a field as no input required if it is hidden, and input required if visible (urgent change justifacation)

 Below is the current java i'm using

<script type="text/javascript">
  _spBodyOnLoadFunctionNames.push("hideFieldsOnStart");
  function hideFieldsOnStart()
  {
   //hide the control at start
   var control = getTagFromIdentifierAndTitle("input","TextField","Urgent Change Justifacation");
   var control2 = getTagFromIdentifierAndTitle("input","DateTimeFieldDate","Proposed Implementation Date");
   control.parentNode.parentNode.parentNode.style.display="none";
   //add an onchange event to the dropdown
   getTagFromIdentifierAndTitle("select","DropDownChoice","Change Type").onchange = function() {ChangeEvent()};
  

SSIS - Passing a date parameter to a SQL Query question again....

  

I need to pass a date string to my sqlcommand inside of my "datareader source".  I read some of the questions about setting expression variables but I can't seem to figure out how to do it.  I pasted the query below.  The table name contains a date in it so I need to pass that date as a string into my sqlcommand at runtime.  Do I create a variable with the entire SQL command in it or can I just create a single variable that holds the date and just reference that in my datasource reader sqlcommand property?  Can someone assist me with the syntax for creating the expression?

SELECT
     pages_20101006.`date` AS full_date,
     pages_20101006.`cat` AS category_no,
FROM
     pages_20101006

Thanks very much,

 

Chris


how to convert date type in SQL query output ?

  

In my database when anyone registers - By default the registration time is saved as UTC universal time zone.

But i want to display everything on the website in (GMT-05:00) Eastern Time (US & Canada)

I am using this SQL QUERY to display registration date:

SELECT TOP (5) Username, CustomerID,  RegistrationDate = CONVERT(VARCHAR(12),RegistrationDate,107)  FROM Customer ORDER BY RegistrationDate DESC

And, i am displaying it like this:

<asp:Label ID="nameLabeldate" runat="server" Text='<%# Eval("RegistrationDate") %>' />

The problem is the output is getting displayed as : 10/20/2010 1:36:01 PM

I know RegistrationDate is datetime stamp that's why i am getting output in this format.

But i want to display RegistrationDate as: Oct 20, 2010 at 1:36pm -> according to (GMT-05:00) Eastern Time (US & Canada) ORDER BY RegistrationDate in Desc (top most will be last registered user)

I need help with sql query by which i should be able to accoplish my desired output..please help...


sql query for month and year of date

  
I have a table with smallint columns for day,month,year. Now I want to select data lets say for month 10,year 2009 to month 2,year 2010. Can anyone help me in writing this query?

XPATH query for date range

  

Hi,

I am pulling the data into a column as XML data type and I want to query within the below XML that is returned.

I want to construct XPATH that allows me to search for a date range where Field Name = Review Date. I want records to be returned whenever the Review Date falls within a date range that I am passing from the UI

<tr2 fieldcode="23" fieldvalue="Periodic Review">

  <LF FieldName="Request Type" />

</tr2>

<tr2 fieldcode="26" fieldvalue="05/04/2010">

  <LF FieldName="Review Date" />

</tr2>

<tr2 fieldcode="27">

  <LF FieldName="Total Number of Accounts" />

</tr2>

<tr2 fieldcode="28">

  <LF FieldName="Total Number of Roles" />

</tr2>

<tr2 fieldcode="27" fieldvalue="28">

  <LF FieldName="Total Number of Accounts" />

</tr2>

<tr2 fieldcode="28" fieldvalue="252">

  <LF FieldName="Total Number of Roles" />

</tr2>


Simple CAML query without Time in the date

  

Hi,

I have written following CAML query.

string.Format("<OrderBy><FieldRef Name='Title' Ascending='False' />

<FieldRef Name='Priority' Ascending='False' />

<FieldRef Name='Status' Ascending='False' />

<FieldRef Name='PercentComplete' Ascending='False' /><FieldRef Name='AssignedTo' Ascending='False' /><FieldRef Name='TaskGroup' Ascending='False' /><FieldRef Name='Body' Ascending='False' /><FieldRef Name='StartDate' Ascending='False' />

T-SQL 2008 date range complex query?

  

Hi, I have SQL 2008 table like

SiteID      TotalBeds     AdmissionDate      DischargeDate

01             10             2010-08-01            NULL
01             10             2010-08-02            2010-08-05
01             10             2010-08-02            NULL
01             10             2010-08-02            NULL
01             10             2010-08-02            NULL<

Query Builder - Show values where date is greater than DateTime now

  

Visual Web Developer 2010 Express

ASP.Net and C#

 

Hi Guys,

My issue is that I am pulled three tables together using the Query Builder and I only want to show data where a specific date is greater than todays date. Here is what i have so far:

SELECT        salesitems.sona, salesitems.sonitem, ZOverdueOrders.ZOOType, ZOverdueOrders.ZOOReason, salesitems.sduedate, salesitems.soitemstate
FROM            salesorders INNER JOIN
                         salesitems ON salesorders.son = salesitems.sona LEFT OUTER JOIN
                         ZOverdueOrders ON salesitems.sona = ZOverdueOrders.ZOOSON AND salesitems.sonitem = ZOverdueOrders.ZOOSONI
WHERE        (salesitems.sduedate > CONVERT(DATETIME, '2010-09-01 00:00:00', 102))
ORDER BY salesitems.sona, salesitems.sonitem

Where it says '2010-09-01 00:00:00' I want that to be the todays date.

 

Is this possible? Can anyone help please?

Thanks in advance for any help!!!!

 

Cheers

Sam


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend