w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
to select latest date and last but-one date from date column in SQL Server 2005
Simple use of ROW_NUMBER: ;WITH OrderedRows as ( SELECT ID,Date,ROW_NUMBER() OVER (PARTITION BY ID ORDER BY Date desc) rn from Table ) select * from OrderedRows where rn <=2

Categories : SQL

Sql Server Return Max date and Date Nearest to and Greater than Max Date
Assuming SQL Server 2005+, you can use this: ;WITH CTE AS ( SELECT [ID], [Type], [Date], RN = ROW_NUMBER() OVER(PARTITION BY [ID] ORDER BY [Date] DESC) FROM YourTable WHERE [Type] = 'A' ) SELECT A.[ID], A.[Date] [Date A], B.[Date] [Date B] FROM (SELECT * FROM CTE WHERE RN = 1) A CROSS APPLY (SELECT TOP 1 [Date] FROM YourTable WHERE [Type] = 'B' AND [ID] = A.[ID] AND [Date] > A.[Date] ORDER BY [Date]) B The results are: ╔════╦═════════════════════════════════╦═════════════════════════════════╗ ║ ID ║

Categories : Sql Server

Need to sort by Date then Hour, then output Date, text Day of week , range of hours SQL Server 2008 R2
This should solve the problem: ; With Streamlined as ( SELECT DATEADD(hour,DATEDIFF(hour,'20010101',adm_ts),'20010101') as RoundedTime, vst_ext_id from TPM300_PAT_VISIT where adm_srv_cd='22126' and adm_ts >= '20130701' and adm_ts < '20130801' ) Select CONVERT(date,RoundedTime) as [Date], DATEPART(weekday,RoundedTime) as [Day of Week], DATEPART(hour,RoundedTime) as [Hour], count(vst_ext_id) as [Total Visits] From Streamlined Group by RoundedTime Order by CONVERT(date,RoundedTime), DATEPART(hour,RoundedTime) In the CTE (Streamlined)'s select list, we floor each adm_ts value down to the nearest hour using DATEADD/DATEDIFF. This makes the subsequent grouping easier to specify. We also s

Categories : Sql Server

Converting Numeric date into date time in SQL Server query
The data is a number type. You have to cast it so a string type before you can use it with the substring function: substring(cast([date] as varchar(18)), 10,2) And for that matter, your ultimate goal should be to convert these values into datetime columns.

Categories : SQL

How to compare 1 set of date with another set of date in SQL Server for overlapping period
Given two date ranges (A and B) you can test whether they overlap by checking if A starts before B finishes and A finishes after B starts. Depending on your data, it should be fairly simple to do this in SQL: If Exists ( SELECT 1 FROM LeaveTable WHERE State In ('Pending', 'Approved') And @ProposedStart < EndDate And @ProposedEnd > StartDate ) BEGIN RAISERROR('The proposed leave overlaps.', 16, 1); Return; END;

Categories : Sql Server

How change format date in SQL Server or how true insert datetime in SQL Server by c#
How are you inserting in the database? From C# code you should always use parameters for passing values. The framework does the conversion for you! More info: http://msdn.microsoft.com/en-us/library/ms254953.aspx http://msdn.microsoft.com/en-us/library/4f844fc7.aspx

Categories : C#

Date values from SQL Server to Informix linked server
Try the format Mmm-DD-YY as per this answer: Linked Informix table in MS SQL Server ignoring criteria Note that it's case sensitive.

Categories : Sql Server

Last Date Required from More Date in SQL Server
Assuming table "T3" Txnid will be T1 , T2 , T3 , T4 not the dates .. I think you need follwing Select T1.Item , Max(T2.Date) From T1 , T2 , T3 Where T1.Item = T3.Item And T3.TxnID = T2.TxnID Group by T1.Item

Categories : Sql Server

Change server date of SQL server 2008
When you run your SQL statement, just add to GETDATE() like this: SELECT ..., DATEADD(DAY, 10, GETDATE()) That would add 10 days to the current date for example.

Categories : SQL

How to set a web service on AMAZON (AWS) which is running a NODEJS server?
Use NODEJS or EXPressJS get the server running ! Then use something like http://Serverip::port to access from your mobile that should work

Categories : Mysql

Query between dates only returns results if a selected date is equal or greater than date in data
The answer is not to use Between. Seperate that line in the WHERE clause into two and explicitly specify wheter or not to include that date by using a >= or just a >. AND date_in > "1/07/2013" or date_in >= "1/07/2013" AND date_in < "1/08/2013" or date_in <= "1/08/2013"

Categories : Mysql

date object returns random date for invalid months/day
That date is not in a format that is specified to be supported by the Date constructor. I'm not surprised to find that most engines call it invalid, but apparently Firefox is attempting to make a date out of that. Even though it's not specified, most engines support month/day/year and all, last I checked, support year/month/day. Firefox appears to be applying year/month/day to the input, where most browsers see the invalid values and go with "invalid." So Firefox is seeing 82 for year (and assuming 1982), 66 for month, and 2005 for day. JavaScript is usually very forgiving about out-of-bound values on dates, moving to the next month and such as necessary. And that's what's happening here: If you take January 1st 1982 and add a further 65 months and 2004 days, you end up on Nov 25 1992. T

Categories : Javascript

Date Box on Form doPost returns as string, not Date Object
e.parameter return indeed always a string. To convert it to a date object you could simply re-create a date like this : var d = e.parameter.date.split('-');// separate day,month and year var dateDate = new Date(d[0],d[1]-1,d[2],0,0,0,0);// month count from 0 >> -1 on d[1] Logger.log(d+' '+dateDate); // check result in the logger // returned value example = 2013-07-31 -> date object construction = new Date(year, month, day, hours, minutes, seconds, milliseconds); EDIT : to set hours , minutes and seconds you should use date.setHours(Number(e.parameter.timeHour.replace(/[^0-9]/g,'')), Number(e.parameter.timeMin.replace(/[^0-9]/g,''))); // use numbers as arguments and eliminate all other characters eventually present (for example if you use "11 hours" instead of sim

Categories : Javascript

Rails 2 + Microsoft SQL Server: ActiveRecord returns -1 but SQL server returns records?
So the solution was to change the way ActiveRecord was making the query. database = ActiveRecord::Base.connection query_for_category_bottle_casecost_case_price = "SELECT ..." category_bottle_casecost_case_price = database.select_all(query_for_category_bottle_casecost_case_price)

Categories : Ruby On Rails

SQL Server Date insert
If you are using the standard import features, you could tweak the import mapping, but I would simply import the data into holding tables "as-is" and then copy to the end table performing your conversion at that time. This works perfectly well select CONVERT(DATETIME,'Jul 14 2005 12:00:00:000AM')

Categories : Sql Server

How to see the last commit in my Gitosis server and date of that
Use the --pretty option, eg. git show --pretty='format:%h %ai' See git-show for more information on "pretty" formats.

Categories : GIT

Server Date resolving issue
your formatters seems to be incorrect, to get the desired output use the code below. H is used for 24 hour format with leading zero. h is used for 12 hour format. date("h:i A");

Categories : PHP

Date format in sql server 2008
Use the date column type instead of datetime http://technet.microsoft.com/en-us/library/bb630352.aspx

Categories : C#

Parsing Italian Date on USA server
You need to set the culture of the current thread to Italian, so it knows to parse Italian dates and not US dates, which it is currently set to. You also don't need to use ParseExact, just use Parse(). Make sure to set it back when you're done with your culturally sensitive code. string foo = "13 Lug 2013 14:15"; Thread.CurrentThread.CurrentCulture = new CultureInfo("it-IT"); DateTime.Parse(foo); Console.WriteLine(foo);

Categories : C#

How to post date and time to server?
Your first approach has the problem, that you omitted the name attributes for the input fields. The name attribute defines what variable is posted by the form. Just write : <input ... type="text" id="StartDate" name="StartDate /> For your second try: But the second one with the razor syntax doesn't. What do you mean with doesn't work? Can you show the rendered HTML?

Categories : Asp Net Mvc

Get server date time with different timezone
Did you try some thing like this? SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); f.setTimeZone(TimeZone.getTimeZone("UTC")); Date date=new Date(); System.out.println(f.format(date)); // current UTC time Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.HOUR_OF_DAY, 5); cal.add(Calendar.MINUTE, 30); System.out.println(f.format(cal.getTime()));// current client side time in UTC Calendar cal2 = Calendar.getInstance(); cal2.setTime(date); cal2.add(Calendar.HOUR_OF_DAY, -8); cal2.add(Calendar.MINUTE, 00); System.out.println(f.format(cal2.getTime()));// current server side time in UTC

Categories : Java

SQL Server inserting Date as 1/1/1900
You have not given it as null, you're trying to insert an empty string (''). You need: INSERT INTO [ABC] ([code],[updatedate],[flag],[Mfdate]) VALUES ('203', '6/12/2013','N/A', NULL) Although really, if you're going to be inserting dates, best to insert them in YYYYMMDD format, as: INSERT INTO [ABC] ([code],[updatedate],[flag],[Mfdate]) VALUES ('203', '20130612','N/A', NULL)

Categories : SQL

using getdate() in sql server to get date as "27Aug13"?
The following will have spaces: SELECT CONVERT(VARCHAR,GETDATE(),6) You can replace spaces: SELECT REPLACE(CONVERT(VARCHAR,GETDATE(),6),' ','')

Categories : Sql Server

Passing C# Date to SQL Server 2008
Don't convert it to a string at all. Keep it as a DateTime. Try to avoid using string conversions as far as you can - every string conversion is a potential source of problems. So: newDR["Close_Date"] = closeDate.Date;

Categories : C#

How to add hours to current date in SQL Server?
DATEADD (datepart , number , date ) declare @num_hours int; set @num_hours = 5; select dateadd(HOUR, @num_hours, getdate()) as time_added, getdate() as curr_date

Categories : Sql Server

default date value of every Friday in SQL Server?
If your current query gives you last Friday, the easiest thing to do is simply to add 7 to it: select dateadd(d, 7-((datepart(weekday, getdate()) + 1 + @@DATEFIRST) % 7), getdate()) ------------------^

Categories : SQL

To Group By Hire Date in SQL Server?
Checkout the DatePart function in SQL. It will break up and group dates based on the interval supplied (ie. day, month, year, etc.) Sample: SELECT DatePart(year,HireDate) ,Count(emplid) ,AVG(salary) FROM Employee WHERE DATEDIFF(YEAR, HireDate, GetDate) <= 4 GROUP BY DatePart(year,HireDate) ORDER BY DatePart(year,HireDate) asc

Categories : Sql Server

How to send emails from my server with a mail server and nodejs
I just had to do this as well, but I am running my node server on an Azure virtual Ubuntu Linux server. I imagine the same steps would work from your home server if you're running Ubuntu. Here is what I found worked: I installed the postfix email server using this guide: https://help.ubuntu.com/community/Postfix It looked like a lot of work at first, but it worked for me pretty easily. I found the easiest way to send the outgoing email from node.js was to use emailjs: http://github.com/eleith/emailjs.git I found that emails sent often end up being marked as spam. To help avoid this, you can go to wherever you manage your domain name (I use enom) and then configure an SPF record to help make your outgoing email look legit. Here is my node.js module to send emails using emailjs:

Categories : Javascript

Date is returning the wrong year in US server
The difference is just one day.. or to be precise few hours from 31st Dec 2010 to 1st Jan 2011. Since UK's time is ahead of US A time in milliseconds like 1293840000000L represents the number of milliseconds that have passed since January 1, 1970 00:00:00.000 GMT. So, the same value for UK and US differs.

Categories : Java

SQL Server date calculations in stored procedures
On March 1st 2014 create the datetime 2014-02-31 23:59:59 No. AFAIK, there isn't any dbms that's so dumb it thinks Feb 31 is an actual date. The SQL statement on line 1 will return the value 'Feb 28 2014 23:59:59'. You can test all your statements by substituting actual dates for GETDATE() and guesswork. In the first query, for example, use SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,'2014-03-01'),0)); ^^^^^^^^^^ You can probably run a version of SQL Server locally. SQL Server 2008 even installs on Windows XP. If you can't bear that, though, there's always sqlfiddle.com.

Categories : Sql Server

SQL Server query for changing status according to date
Sounds like a simple UPDATE statement: UPDATE table SET status = 0 WHERE CAST(StartDate AS DATE) = CAST(EndDate AS DATE) AND CAST(StartDate AS DATE) = CAST(GETDATE() AS DATE)

Categories : SQL

Date parameter in SQL Server stored procedure from ASP.NET
I would suggest you don't store anything in the textbox using regional, ambiguous formats like dd/mm/yyyy. If you use an unambiguous format like YYYYMMDD, you're not going to have any issues. And if users are picking from a calendar control or something, it should be easy to separate the date you present to them from the date you pass to the database.

Categories : Asp Net

Date Format Changed when uploaded to Server
The results of using date format specifiers like "Long Date", "Short Date", etc. will depend on the settings for those presets in Windows' Regional Settings for the account under which the application runs. In your case those settings on the server are different from those on your local machine. If you really want a particular format then you should explicitly specify it, e.g. something like Format(Date(), "dddd, mmmm d, yyyy") ...should give you Tuesday, July 2, 2013

Categories : Ms Access

How to get Discount Start and End Date from Commerce Server?
The following code snippet demonstrates how to get the StartDate and EndDate for a Commerce Server Discount. This assumes you are using the Commerce Server 2007 API and that you know the ID of the discount you want the dates from. //The discount id we want to get dates from. var discountId = 12;//Set to your ID. //Configure the Commerce Server site name. var siteName = "StarterSite"; //We need a MarketingContext instance so we can access the marketing API. var mc = MarketingContext.Create(siteName, null, AuthorizationMode.NoAuthorization); //Get our discount. var discount = (Discount)mc.CampaignItems.GetCampaignItem(discountId); //Voila. Start and End dates. var startDate = discount.StartDate; var endDate = discount.EndDate; Note: The MarketingContext.Create overload, returns a

Categories : C#

Error when updating date field in sql server using c#
At the surface, this is simply a formatting issue - but "fixing the formatting" is the wrong way to address this; you should parameterize, such that formatting simply does not apply. Dates don't have a "format", as such - they are just numbers. For example, what we should probably execute is: UPDATE qmsAuditFindings SET FindDate=@findDate WHERE AuditID=@auditId To do that you get the DateTime value in your .NET code, and do something like: DateTime findDate = ... int auditId = ... using(var cmd = connection.CreateCommand()) { cmd.CommandText = "UPDATE qmsAuditFindings SET FindDate=@findDate WHERE AuditID=@auditId"; cmd.Parameters.AddWithValue("findDate", findDate); cmd.Parameters.AddWithValue("auditId", auditId); cmd.ExecuteNonQuery(); } or more simply with a

Categories : C#

How to Send data from Android app to a Server date?
You are calling postData(); in onCreate. You haven't received any position at this point. You have to move postData(); to when you actually receive a Location, i.e. in onLocationChanged. You'll also probably need to put that in an AsyncTask.

Categories : Android

Sql query with date comparison in Sql Server 2012
SELECT * FROM dbo.YourTable WHERE dt >= DATEADD(DAY,-15,GETDATE()) If you want the whole day without worrying about the time part: SELECT * FROM dbo.YourTable WHERE dt >= DATEADD(DAY,-15,CAST(GETDATE() AS DATE))

Categories : SQL

GWT: date format changing itself in firefox when run on server
Use the GWT DateTimeFormat to show dates in a uniform manner. DateTimeFormat.getFormat("MM/dd/yyyy h:mm:ss a").format(YOUR_DATE); will give you a String.

Categories : Gwt

SQL Server convert to optimal short date
not really that hard, if you are using sqlserver 2008+ cast(@date as date) or convert(date, @date) Since you are using sqlserver 2005 CONVERT(CHAR(10), @date, 121) However if you are going to compare with another date, keep the datetime format and remove the time part: dateadd(day, 0, datediff(day, 0, @date))

Categories : SQL

Date.js vs Moment.js (and server-side formatting)
You are correct. Moment.JS does not handle #2 .... only Date.js does. As for server vs client... I tend to unload calculations to the client unless I am building a mobile app. In the end let the application/project determine where computation should occur.

Categories : Ruby On Rails



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.