getdate

Getdate() function to get date for my timezone

吃可爱长大的小学妹 提交于 2019-12-19 02:47:16
问题 I would love to insert a default value into a column with data type datetime2(7). However, because my website is hosted on a server in a different timezone, the getdate function doesn't work properly. I wonder if there is a solution to this. I have done some research and found two ways. First is to use GetUTCDate() function. However, I would need to do the conversion when I display the information. I am sure my web application is used for only my timezone. So I would like to avoid this.

How to get a Date from a JSON object

风流意气都作罢 提交于 2019-12-18 12:45:57
问题 I have a JSON object, which have one field that is a birthdate: JSONObject obj = new JSONObject(response); User user = new User(); user.setuserID(obj.getString("userID")); user.setisMale(obj.getBoolean("isMale")); user.setEmail(obj.getString("email")); // user.setBirthdate(obj.getDate("birthdate")); user.setLastName(obj.getString("lastName")); user.setFirstName(obj.getString("firstName")); But the method getDate() does not exist in JSONObject. How can I set the Birthdate in my User object?

Selecting GETDATE() function twice in a select list— same value for both?

萝らか妹 提交于 2019-12-18 07:44:09
问题 I have a SELECT statement that uses GETDATE() for two different column values. I'm wondering if by the nature of things those two separate function calls in the same SELECT will return identical values every time? 回答1: No they aren't guaranteed to return identical values every time. Each individual reference to GetDate() is a runtime constant and will keep its value throughout the query... SELECT GETDATE() FROM large_table will return the same value in all rows regardless of how long the

JavaScript's getDate returns wrong date

本秂侑毒 提交于 2019-12-17 04:27:53
问题 The following script returns 20 instead of 21! var d = new Date("2010/03/21"); document.write(d.getDate()); What am I doing wrong? Is this a JavaScript bug? 回答1: The Date.parse method is implementation dependent ( new Date(string) is equivalent to Date.parse(string)). While this format will be available on modern browsers, you cannot be 100% sure that the browser will interpret exactly your desired format. I would recommend you to manipulate your string, and use the Date constructor with the

Disable a link on Friday at 4PM and enable on Sunday 7:00AM

陌路散爱 提交于 2019-12-12 06:18:02
问题 I'm trying to use a bit of JavaScript to get the date and time and then use some jQuery to enable/disable a link. So I have something like this, <a href="link.html" title="Link"> <img src="link.gif" alt="link" /> </a> And between Friday at 4PM and Sunday at 7:00AM, I'd like to have it just say this, <img src="link.gif" alt="link"> How would I be able to do that? P.S. I would prefer to have the link hardcoded rather than to have it propped with the JavaScript... 回答1: here's a working version

Force recalculation of GetDate() for each row

馋奶兔 提交于 2019-12-12 00:40:04
问题 When running this command in SQL Server Management Studio UPDATE LogChange SET Created = GETDATE() WHERE id > 6000 something strange happens.. :) All rows get the same value in the Created column. How do I "force" SQL Server to recalculate the GetDate for every row? 回答1: A cursor solved it declare @id int; Declare toLoop cursor for select Id from LogChange where id > 6000 OPEN toLoop FETCH NEXT FROM toLoop INTO @id WHILE @@FETCH_STATUS = 0 BEGIN Update LogChange set Created = GETDATE() where

Date format from MSSQL to other

僤鯓⒐⒋嵵緔 提交于 2019-12-11 16:49:10
问题 In MSSQL I have columns with date (only date, without time). It was saved with this function: ROUND(CAST(GETDATE() AS REAL), 0, 1) + 36163 **(ex. 77009)** How I can format this date (month etc.) with PHP, MySQL or even MSSQL. For example: 77009 = 2011-11-01. 回答1: For Sql Server SELECT CONVERT(DateTime,XXX-36163) eg. SELECT @val = ROUND(CAST(GETDATE() AS REAL), 0, 1) + 36163 SELECT CONVERT(DateTime,@val-36163) 回答2: MySQL: SELECT SEC_TO_TIME(YOUR_DATE_COLUMN); Please refer to the function in

getdate() in mysql

流过昼夜 提交于 2019-12-11 07:34:48
问题 I am creating a system which updates the user activity when something is done. I have a variable $userhistory= 'User edited '.$info.' on July 14 2010 or (07-14-2010); I want to know how can i get the date automatically. for sql query i am using NOW(), but in a variable like $userhistory how do i get the date and it want it only in either of these forms. not along with the time. Also, I am updating the column userhistory in the database, which is a text field. Is this the correct way to do it?

SQL Server How to get Date Difference excluding Weekends and Holidays?

最后都变了- 提交于 2019-12-11 04:46:14
问题 I have this table: tbl_Sales ---------------------------------------- |Item_Code|Sold|Date | |---------+----+-----------------------| |BBPen100 |30 |2017-04-17 00:00:00.000| |BBPen100 |21 |2017-04-13 00:00:00.000| |BBPen100 |13 |2017-04-12 00:00:00.000| |XSHIRT80 |0 |2017-04-17 00:00:00.000| |XSHIRT80 |24 |2017-04-14 00:00:00.000| |XSHIRT80 |9 |2017-04-13 00:00:00.000| |XSHIRT80 |5 |2017-04-12 00:00:00.000| |YBSHADE7 |0 |2017-04-17 00:00:00.000| |YBSHADE7 |6 |2017-04-15 00:00:00.000|

Accuracy of SYSDATETIME Data Type in SQL Server

不羁的心 提交于 2019-12-11 00:09:48
问题 I have done some testing using the SYSDATETIME in stored procedure in SQL Server 2008. I have setup a table with a datetime2(7) with a IDENTITY field. I understand the difference between the precision and the accuracy of this data type however, I noticed an unusual result when inserting multiple records from this example: declare @counter int set @counter = 0 while @counter < 100000 begin set @counter = @counter + 1 INSERT INTO t ([now]) VALUES (SYSDATETIME()) end I looped through using an