getdate

Simulate current date on a SQL Server instance?

点点圈 提交于 2019-12-08 18:27:24
问题 Is it possible to change the datetime for a particular database on SQL Server? Is it tied to the operating system's date/time? We wish to simulate a future datetime for testing purposes i.e. so the GETDATE() returns a date in the future. It's got to be in a semi-production (staging) environment so unfortunately changing the OS date / time isn't an option for us. In an ideal world we'd spin up a virtual server, but also not really an option at the moment. 回答1: As stated, by others, No. A

Convert getdate() to int

故事扮演 提交于 2019-12-08 17:15:34
问题 When I run the following query: select convert(int, getdate()) I get the result: ----------- 41238 (1 row(s) affected) Does anyone knows what does this mean? 回答1: Its the number of days since I think 1/1/1900 , sql-server keeps the number of days since then. Try dividing that number by roughly 365. You should get the value back in years (112). Since 1900 + 112 = 2012 回答2: This is because SQL natively keeps the number of days since 01/01/1900 The decimal after the integer value is the time. 32

Set default value in column IF condition is met in SQL 2008

这一生的挚爱 提交于 2019-12-08 12:55:33
First of all, I'm very new with SQL query, so I apologize if I sound ignorant... I have a database that has a stored job to drop and create a table every hour. The table looks like this, except there is data for every hour in between 1 and 24 Name Hour1 Hour24 Point 1 OUT 4 5 Point 1 IN 26 22 Point 2 OUT 46 44 Point 2 IN 0 0 Point 3 OUT 18 19 Point 3 IN 56 51 Point 4 OUT 111 100 Point 4 IN 0 0 Point 5 OUT 0 0 Point 5 IN 42 46 Point 6 IN 210 211 After the drop and create, the database adds a column at the end called date and sets todays date as the default. My problem is when importing the data

Set default value in column IF condition is met in SQL 2008

寵の児 提交于 2019-12-08 08:43:27
问题 First of all, I'm very new with SQL query, so I apologize if I sound ignorant... I have a database that has a stored job to drop and create a table every hour. The table looks like this, except there is data for every hour in between 1 and 24 Name Hour1 Hour24 Point 1 OUT 4 5 Point 1 IN 26 22 Point 2 OUT 46 44 Point 2 IN 0 0 Point 3 OUT 18 19 Point 3 IN 56 51 Point 4 OUT 111 100 Point 4 IN 0 0 Point 5 OUT 0 0 Point 5 IN 42 46 Point 6 IN 210 211 After the drop and create, the database adds a

Get Date From Google Custom Search API

◇◆丶佛笑我妖孽 提交于 2019-12-07 04:24:49
问题 How i can get date data like that google search. Is it possible to get it? I never found it in google custom search API. The second picture i post is only snippet which got date and some description about it. The first picture from google search news and the second is google custom search 回答1: The following API request returns metadata, like published time, only if it is mentioned in its HTML source. GET https://www.googleapis.com/customsearch/v1?key=APIkey&cx=CustomSearchEngineID&q=rambo And

Get Date From Google Custom Search API

泪湿孤枕 提交于 2019-12-05 09:39:21
How i can get date data like that google search. Is it possible to get it? I never found it in google custom search API. The second picture i post is only snippet which got date and some description about it. The first picture from google search news and the second is google custom search The following API request returns metadata, like published time, only if it is mentioned in its HTML source. GET https://www.googleapis.com/customsearch/v1?key=APIkey&cx=CustomSearchEngineID&q=rambo And refer to the "metatags" section And Voila! Hope that helps :) 来源: https://stackoverflow.com/questions

Echo all months with days calendar

拈花ヽ惹草 提交于 2019-12-04 14:52:21
问题 I am using the code below to echo the current month. How can i enhance it so that is shows all the months with the names and days and dates.. Code: <?php $today = getdate(); $firstDay = getdate(mktime(0,0,0,$today['mon'],1,$today['year'])); $lastDay = getdate(mktime(0,0,0,$today['mon']+1,0,$today['year'])); ?> <?php echo '<table>'; echo ' <tr><th colspan="7">'.$today['month']." - ".$today['year']."</th></tr>"; echo '<tr class="days">'; echo ' <td>Mo</td><td>Tu</td><td>We</td><td>Th</td>';

Precision of SQL Getdate?

你。 提交于 2019-12-04 04:21:19
问题 I am experimenting with a program that inserts data into an SQL 2005 Server database (on XP SP3) at high rate of speed. (This is for collecting timing data so I can evaluate different aspects of my design). My basic set up involves inserting a data into a table like the following (and using an SP that just specifies the payload field): create table data ( Id int PRIMARY KEY Identity, payload datatime not null, inserted datetime default (getdate()) not null ) Note that both datetime fields

Echo all months with days calendar

依然范特西╮ 提交于 2019-12-03 09:15:27
I am using the code below to echo the current month. How can i enhance it so that is shows all the months with the names and days and dates.. Code: <?php $today = getdate(); $firstDay = getdate(mktime(0,0,0,$today['mon'],1,$today['year'])); $lastDay = getdate(mktime(0,0,0,$today['mon']+1,0,$today['year'])); ?> <?php echo '<table>'; echo ' <tr><th colspan="7">'.$today['month']." - ".$today['year']."</th></tr>"; echo '<tr class="days">'; echo ' <td>Mo</td><td>Tu</td><td>We</td><td>Th</td>'; echo ' <td>Fr</td><td>Sa</td><td>Su</td></tr>'; ?> <?php echo '<tr>'; for($i=1;$i<$firstDay['wday'];$i++){

How to print GETDATE() in SQL Server with milliseconds in time?

杀马特。学长 韩版系。学妹 提交于 2019-12-03 08:52:16
问题 I want to print GETDATE() in SQL Server 2008, I need the time with milliseconds (this is for debugging purpose - to find sp's execution time ) I find this Difference SELECT GETDATE() returns 2011-03-15 18:43:44.100 print GETDATE() returns Mar 15 2011 6:44PM I think SQL Server automatically typecast in print functionality. I need to print the date like this 2011-03-15 18:43:44.100 Thanks for your help. 回答1: First, you should probably use SYSDATETIME() if you're looking for more precision. To