Getting The Past 24 Hours Worth Of Data?

Aug 16, 2007

I have a need to query my data and return only the last 24 hours (versus last day) worth of data.

My date and time fields are called:

calc_date = the date
Calc_time= the time
RealTime = Calc_date+Calc_time as realtime

I know if I use getdate()-1 that will get me the last day, but I need the last 24 hours. Any ideas on how would I do this?

View 6 Replies


ADVERTISEMENT

How Can I Retrieving Records By Past One Week,past Month, Past Quarter Of Year And Then Half Year.

Apr 30, 2007

Hi every one,
I have a database table and currently users may retrieve records for a specified date range by providing the start and end dates and then records between those dates provided are retrieved. For example if users wanted to view all records entered in april, they would have to select 04/01/2007 as the start date and then 04/30/2007 as the end date. The records for april would then be displayed in a gridview.
How can configure my sql query such that instead the user selectes a month from a dropdownlist of 12 months. I would love a user to just select the desired month from a list instead of selecting start and end dates. Eg if they are intrested in a report for june, then they should just select june from the list instead of specifying the start and stop dates. HOW can i achieve this.

View 4 Replies View Related

Need To Get Just Last 2 Years Worth Of Data

Jun 23, 2008

SELECT * FROM TEST NOLOCK
WHERE FY_CD = DATEPART(YEAR, GETDATE())

This gives me last years - but they want last years 2007 and 2008

Any suggestions

View 3 Replies View Related

Which Sort Of Data (from Application Architecture) Point Of View It's Worth To Put In XML Datatype (MS SQL 2005)?

Mar 20, 2008

Which sort of data (from application architecture) point of view it's worth to put in XML datatype (MS SQL 2005)?

View 2 Replies View Related

How To Get Data For Past 7 Weeks

Nov 21, 2007

All,

I am trying to design a graph to shows out build status for past 7-8 weeks. I have to write the SQL query first.

After spending a good chunk of time, I could get some basic chart going. Problem is that I could give it a starting time till now (static) but I am not sure how to get the results for past 7-8 wekks.

1) What is a good approach for this since time is not static and it is changing.

any example or piece of sql syntax is greately appreciated.

Thaks in advance,

aa-

View 6 Replies View Related

SQL Server 2014 :: Return Data Between Two Dates In The Past?

Jun 6, 2015

why the statement "where WD.WRKD_WORK_DATE BETWEEN DATEADD(DD, -6, GETDATE()) AND GETDATE()) = 0' is successful, but "WD.WRKD_WORK_DATE BETWEEN (DATEADD(DD, -16, GETDATE())) AND (DATEADD(DD, -3, GETDATE()))" is an invalid statement? I've tried a lot of different syntax variations of this statement and cannot get to work between two lookback dates.

View 9 Replies View Related

Transact SQL :: To Display Days Hours Mins Format Based On Business Hours

Apr 22, 2015

I want to display Days Hours Mins Format.

I am Having two columns Like below,

Col1 (in days)    col2 (In Hours : Mins)
3days  4:5 

In this first have to  add Col1 and Col2 (Here one day is equals to 9 hours ) so the addition is 31.5

From this 31.5 I should display 3 Days 4 Hours 30 Mins because 31.5 contains 3 (9 hours) days 4 Hours and .5 is equals to 30 mins.

View 6 Replies View Related

Breaking Down Total Hours Worked Into Day And Evening Hours

Sep 21, 2006

I have data coming from a telephony system that keeps track of when anemployee makes a phone call to conduct a survey and which project numberis being billed for the time the employee spends on that phone call in aMS SQL Server 2000 database (which I don't own).The data is being returned to me in a view (see DDL for w_HR_Call_Logbelow). I link to this view in MS access through ODBC to create alinked table. I have my own view in Access that converts the integernumbers for start and end date to Date/Time and inserts some otherinformation i need.This data is eventually going to be compared with data from someelectronic timesheets for purposes of comparing entered hours vs hoursactually spent on the telephone, and the people that will be viewing thedata need the total time on the telephone as wall as that total brokendown by day/evening and weekend. Getting weekend durations is easyenough (see SQL for qryTelephonyData below), but I was wondering ifanyone knew of efficient set-based methods for doing a day/eveningbreakdown of some duration given a start date and end date (with theday/evening boundary being 17:59:59)? My impression is that to do thiscorrectly (i.e., handle employees working in different time zones,adjusting for DST, and figuring out what the boundary is for switchingfrom evening back to day) will require procedural code (probably inVisual Basic or VBA).However, if there are set-based algorithms that can accomplish it inSQL, I'd like to explore those, as well. Can anyone give any pointers?Thanks.--DDL for view in MS SQL 2000 database:CREATE VIEW dbo.w_HR_Call_LogASSELECT TOP 100 PERCENT dbo.TRCUsers.WinsID, dbo.users.username ASInitials, dbo.billing.startdate, dbo.billing.startdate +dbo.billing.duration AS EndDate,dbo.billing.duration, dbo.projects.name ASPrjName, dbo.w_GetCallTrackProject6ID(dbo.projects.descript ion) AS ProjID6,dbo.w_GetCallTrackProject10ID(dbo.projects.descrip tion) AS ProjID10,dbo.billing.interactionidFROM dbo.projects INNER JOINdbo.projectsphone INNER JOINdbo.users INNER JOINdbo.TRCUsers ON dbo.users.userid =dbo.TRCUsers.UserID INNER JOINdbo.billing ON dbo.users.userid =dbo.billing.userid ON dbo.projectsphone.projectid =dbo.billing.projectid ONdbo.projects.projectid = dbo.projectsphone.projectidWHERE (dbo.billing.userid 0)ORDER BY dbo.billing.startdateI don't have acess to the tables, but the fields in the view comethrough as the following data types:WinsID - varchar(10)Initials - varchar(30)startdate - long integer (seconds since 1970-01-01 00:00:00)enddate - long integer (seconds since 1970-01-01 00:00:00)duration - long integer (enddate - startdate)ProjID10 - varchar(15)interactionid - varchar(255) (the identifier for this phone call)MS Access SQL statement for qryTelephonyData (based on the view,w_HR_Call_Log):SELECT dbo_w_HR_Call_Log.WinsID, dbo_w_HR_Call_Log.ProjID10,FORMAT(CDATE(DATEADD('s',startdate-(5*60*60),'01-01-197000:00:00')),"yyyy-mm-dd") AS HoursDate,CDATE(DATEADD('s',startdate-(5*60*60),'01-01-1970 00:00:00')) ASStartDT,CDATE(DATEADD('s',enddate-(5*60*60),'01-01-1970 00:00:00')) AS EndDT,DatePart('w',[StartDT]) AS StartDTDayOfWeek, Duration,IIf(StartDTDayOfWeek=1 Or StartDTDayOfWeek=7,Duration,0) ASWeekendSeconds,FROM dbo_w_HR_Call_LogWHERE WinsID<>'0'

View 3 Replies View Related

Converting Decimal Hours To Hours And Minutes

May 13, 2008

I have a float variable that holds a decimal number of hours.

So 1.5 equals 1 hour 30 minutes.

I need to change this to the format 1:30

Any idea how to do this?

View 10 Replies View Related

What Data Type Is Best For Hours

Feb 1, 2007

What is the best data type to use when tracking hours, for example;
2.30 < this is stored in DB
(two hours and thirty minutes)
5.15 < this is stored in DB
(5 hours and fifteen minutes)

View 15 Replies View Related

Filter Data By Hours

May 22, 2008



Hello!

I need to create a report that shows daily events per hours, like this:

15.5. Example
00:00 8
01:00 9
02:00 34

Is this possible? The data should be filtered by the datetime. If the datetime is for example 15.5.2008 00:45, it goes to the first row of that example table I created.

Edit. I am using Sql server 2005.

Thanks,

Aleksi Rytkönen

View 4 Replies View Related

Is MCDBA Worth It?

Sep 23, 2005

Is MCDBA worth of the time and money one has to put into to acheive it?
I am talking in terms of getting a job.
Do you think after getting MCDBA you have gained sustantial knowledge about the subject?

I havent appeared for any of the MS exams as yet
but would like to start with 70 228 and 70 229.

I like reading BOL, but i guess for certfn exams you have to have a diff approach...

View 13 Replies View Related

Issue Charting Data Over Last 24 Hours...

Sep 5, 2007

I have a table which contains data regarding calls to the Help Desk, I want to chart this using a simple line chart in SSRS 2005 with the chart displaying the number of cases opened by the help desk each hour for the last 24 hours. Although our Help Desk provides 24/7 support, there are periods of an hour in which no calls are received. The issue I'm having is I want the chart to still display these hour periods of time even though there are no records created in the time span. I want the x-axis to display every hour for the last 24 hours.

Anyone have any suggestion on how I can accomplish this? The only idea I've come up with is creating a new table containing a list of every hour in a day and referencing this to build the x-axis...but it seems as though it should be easier than that?

Thanks in advance for any input or assistance.

View 1 Replies View Related

Database De-normalization, Is It Worth It?

Feb 14, 2008

Is it worth it for performance purposes to create additional fields in table so that when a database query is made two tables don't need to be joined?

View 1 Replies View Related

Is It Worth Upgrading To SQL2000

Feb 2, 2001

I currently have several databases running under SQL 7. My Shop is migrating to Windows 2000. I was wondering, does SQL 7 run as good under Win 2000 like it does under Win NT? Since we are migrating should I upgrade to SQL 2000 or should I stay with SQL 7?

Thanks.

View 1 Replies View Related

SQL 2000 Parallelism - Is It Worth It?

Jul 23, 2005

Hi,I have a sql 2000 server with 8 processors, server settings are asdefault. I read on Technet that it is good practise to remove thehighest no. processors from being used for parallelism, correspondingto the no. of NICs in the server. One of our 3rd party developers hasrecommended only allowing one processor to be used as there is aperformance hit by the server working out which processor to use. Doesanyone have a definitive answer to this? I suspect he's wrong but I'dlike some hard evidence if possible, thanks.Kev.

View 3 Replies View Related

Best Method Or Is It Even Worth The Effort?

Jun 21, 2007

Hi,



I have a question regarding a project I am working on and I'm not sure what the best way to do it may be, I am new to SSIS and would like to gain some exposure using it, but don't know if this project is overkill or even possible using SSIS.



*** PROBLEM ****

Basically I have a large number of flat files each file contains different columns and data. What I want to do is import all of the data from the flat files into corresponding tables in SQL Server. The tables in SQL server are already defined with data structure to match each file. The first 10 characters of the flat file are also the same name as the SQL table. So it seems easy enough to just import flat file to table one by one, but I cannot figure out how to match the flat file structure to each table without setting up a task for each table (there are roughly 50-60 tables). Another reason I want to do it with SSIS is these flat files have to be imported on a weekly basis.

**********************



Is it in my best interest to just create a stored procedure that basically loops through the files and imports the data? Or do you think using SSIS is the best solution? I have looked at SSIS a bit and thought maybe I could use the bulkinsert task, but it appears it cannot dynamically change due to column specs. I figured out how to loop through the flat files using the foreach task, but I could only get it to import into one SQL table. I also started looking at the dataflow task and thought about creating a script task, but I'm not sure if that would work before I spend a lot of time trying to figure that out.



Any suggestions or thoughts are appreciated.



Thank you

View 5 Replies View Related

Is Lineage More Trouble Than It's Worth?

Oct 24, 2006

Very often during dev. I add processes that don't change the metadata of a data item (for example a new sort) yet the linieage id is changed.  This causes lots of headaches down the pipe.  If metadata of a data item is not changed in the pipe, why is the lineage id changed?

If lineage is not smart enough to figure out when some metadata was actually changed, should it be made smart enough?  Or optional?

Ken

View 10 Replies View Related

Right Data Type To Store Hours And Minutes

Mar 1, 2007

Hello friends
what is the right datatype to store the hours and minutes part in the database?
i found some info which says we have to convert the duration(hrs and min) into minutes and then store
is it the right approach?
Regards
Sara

View 1 Replies View Related

Keeping 5 Days Worth Of Backups

May 13, 2008

Hey all,

I'm trying to set up a backup schedule in SQL 2005 that will keep 5 .bak files within the folder I specify. I can get it to keep one backup only even though I specify that it is to keep 5 days worth of backups. Each backup happens at 12:00 am. I think the problem I may be having is I don't know how to get the maintenance plan to name the file mmddyyyy.bak or whatever it may need to determine that the file is 5 days old. Currently I am specifying a name of gmsqlbackup.bak. Any idea's that may help me out?

View 2 Replies View Related

Not Last 24 Hours Data But Yesterday Data

Dec 26, 2007

How do I write an expression which shows only previous day data. I use the following where condition .



(DATEDIFF(dd, 0,MoneyFlowTransaction.ProcessedTime) = DATEDIFF(dd, 0, GETDATE()) - 1)

I'm wondering whether this one shows yesterday data or last 24 hours data?

Thanks
P/S;

Also for my reports I used the following query.





Code Block
SELECT ProcessedTime, GETDATE() - 1 AS Yesterday, GETDATE() - 2 AS DaybfYesterday
FROM MoneyFlowTransaction





This shows data before 24 hours. Not exactly yesterday data(calander date).
can any one help me to fix this pls?

View 1 Replies View Related

Import Data From Textfile Evry 2 Hours Automtically

Feb 23, 2001

Hello,

Can somebody please help me with the following problem.

I want to import data from a textfile called "Links.txt" into a SQL-server database called "LinkData". The data in this textfile is separated by pipelines. And this import should be done every 2 hours automatically. How can I make a proces or something in SQL server 7 that will fill the database with the data out of this textfile every 2 hours. Please help me. I really don't know.

greetings

R. Jacobs

View 2 Replies View Related

Import Data From Textfile Evry 2 Hours Automtically WITH DTS

Feb 23, 2001

I want to import data from a textfile called "Links.txt" into a SQL-server database called "LinkData". The data in this textfile is separated by pipelines. And this import should be done every 2 hours automatically. How can I make a proces or something in SQL server 7 that will fill the database with the data out of this textfile every 2 hours. Please help me. I really don't know.

I was planning on using DTS for this Only I really don't know how. I tried it with "Data driven query task" in combination with "Text file (source)" and "Microsoft OLE DB Provider for SQL Server". But when I run it, it gives an error. What am i doing wrong??? Help me please

thanx

View 1 Replies View Related

Nvarchar Fields With Time Data - Calculate Difference In Hours

Sep 19, 2014

I have two nvarchar fields with time data 12:34:34 and the second one 12:34 I want to calculate the difference in Hours. The first field is called (OTIM) the second field is called (ReportedTime) if the name matters. I tried substring to trim the OTIM, I am unable to make it work.

View 3 Replies View Related

Past Queries

Oct 9, 2007

Is there an option is SQL Server or SSMS to view the past few already executed queries.

I need to check what are all the queries fired on SQL server.




------------------------
I think, therefore I am - Rene Descartes

View 6 Replies View Related

Copy And Past A Row

Mar 30, 2007

Hello all,



Is there a way for me to copy a row, do some modification in a certain row and insert it to the same table as a new row?



Forward with thousand thanks.



Best regards,

Tee Song Yann

View 8 Replies View Related

Past Due Report

Jan 24, 2008

Hello All
Our Collection team has a report that has an error that I'm tring to fix. The Person who created this report just hard coded the current month due as =MonthName(Month(Fields!CurrentDue.value) &" " &year((Fields!CurrentDue.Value).
For the Year 2007 it works fine. But now that the new year has started the report Current Month Due read Dec 2008, but it should be Dec 2007. I thought Of putting in some IIF statements but there has to be a easier way. Is there a function that check the past due and automatically increases the year by one. Say the bill in sent in Nov 2007 past due should be 30 days, Dec 2007. 60 Day should be Jan 2008 and so one.

Last Report Hours

=monthname(month(Fields!LastReportedHours.Value)) & " " & year(Fields!LastReportedHours.Value)

Days Past Due

=Fields!DaysPastDue.Value

Current Month Due

=monthname(month(Fields!CurrentDue.Value)) & " " & year(Fields!CurrentDue.Value)

Current Output
last reported Days Past due Current Month Due

September 2007 75 Days December 2008

Output should be!
last reported Days Past due Current Month Due

September 2007 75 Days December 2007

View 4 Replies View Related

Past Two And Next Two Quarters

Nov 20, 2015

I want past two and next two quarters from the present quarterLike now its 4th quarter i should get 3rd and 2nd quarter and next two quarters that is 1st and 2nd also this is my table and when the year changes data is not fetched correctly

View 10 Replies View Related

Past And Future Date

Aug 26, 2006

How should I find the dates for 3 days past and 5 days future. Such as TodayDate-3 and TodayDate+5 base in the date only, discarding the time?

View 5 Replies View Related

How Can I Calculate The Days Past Due

Apr 20, 2008

If I have and invoice date column and I want to now what invoices are 15 days past due or 30 days past due, how do I do this in a where clause?
WHERE tblInvoices.InvoiceDate ???

View 1 Replies View Related

How Calculate 18 Months Past ?

Nov 13, 2000

I have a database of the table payments
and I want to create another table with
the olds payments (18 months past)
a have a field with the payment date
date_pay.
How I can do that?

Thanks

Luiz Lucasi

View 2 Replies View Related

Trying To Obtain Past Dates

Oct 5, 2006

Hi,

I have a date column and I am trying to build a query that will give me the dates > 48 hours ago (in the past).

For example using todays date 2006.10.05 and time 23:00 I would be looking for the dates prior to 2006.10.03 and time 23:00.

Your help is greatly appreciated!

Thanks!

View 2 Replies View Related

Jobs Executed In The Past

May 16, 2008

How to find the jobs executed in the past for a perticular period.
e.g. jobs ran between 2-3pm in the past.

I am using sysjobhistory but not really able to use column run_time

------------------------
I think, therefore I am - Rene Descartes

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved